Build for Android Fails!

Software Versions:

Cocos2d-x version: 3.2
Python version:  2.7.5
Java version “1.8.0_11”
Ant version: 1.9.4
NDK version: r10
Eclipse ADT: x86_64-20140702

The error occurs when I try to execute the command “python ./build_native.py”:

Error description:

The Selected NDK toolchain version was 4.8 !
Android NDK: WARNING:jni/…/…/cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries    
Android NDK: WARNING:jni/…/…/cocos2d/cocos/platform/android/Android.mk:cocos2dxandroid_static: LOCAL_LDLIBS is always ignored for static libraries    
make: Entering directory /Users/sandrojack/Desktop/Tutorial/proj.android' [armeabi] Compile++ thumb: cocos2dx_static <= CCBundleReader.cpp [armeabi] Compile++ thumb: cocos2dx_static <= CCImage.cpp [armeabi] Compile++ thumb: cocos2dx_static <= CCThread.cpp [armeabi] Compile++ thumb: cocos2dx_static <= CCAffineTransform.cpp jni/../../cocos2d/cocos/./3d/CCBundleReader.cpp:94:23: error: return type of       out-of-line definition of 'cocos2d::BundleReader::tell' differs from that in       the declaration ssize_t BundleReader::tell()                       ^ jni/../../cocos2d/cocos/./3d/CCBundleReader.h:90:14: note: previous declaration is       here     long int tell();              ^ 1 error generated. make: *** [obj/local/armeabi/objs-debug/cocos2dx_static/3d/CCBundleReader.o] Error 1 make: *** Waiting for unfinished jobs.... make: Leaving directory/Users/sandrojack/Desktop/Tutorial/proj.android’
Traceback (most recent call last):
  File “build_native.py”, line 159, in
    build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
  File “build_native.py”, line 146, in build
    do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
  File “build_native.py”, line 82, in do_build
    raise Exception(“Build dynamic library for project [ " + app_android_root + " ] fails!”)
Exception: Build dynamic library for project [ /Users/sandrojack/Desktop/Tutorial/proj.android ] fails!

i had the same issue and after looking at the source code, i changed the return value of
tell() from long in to ssize_t in CCBundleReader.h line 90 as this method return m_position which declared as ssize_t

2 Likes

I changed the ndk-r10 to ndk-r9d and the problem was solved, but thank you very much for reply anyway.

sorry but how to download ndk-r9d ? i cant fiend any link for it ?

here https://dl.google.com/android/ndk/android-ndk-r9d-darwin-x86_64.tar.bz2

well, it’s a known bug that 3.2-final can’t be compiled properly with android ndk r10. We will fix this bug sooner.

It is fixed in this PR: https://github.com/cocos2d/cocos2d-x/pull/7526.
Sorry about it.

thanks for fixing this bug

But there is link error in lua test cases. The error message is

/Users/minggo/bin/android/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: /Users/minggo/bin/android/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.8/libgcc.a(pr-support.o): multiple definition of '_Unwind_GetLanguageSpecificData'
/Users/minggo/bin/android/android-ndk-r10/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: /Users/minggo/bin/android/android-ndk-r10/sources/cxx-stl/llvm-libc++/libs/armeabi/thumb/libc++_static.a(Unwind-EHABI.o): previous definition here

But i don’t know why it happened.

I have posted a news for compiling and linking errors.
We suggest you not use ndk r10. It has bugs.

thank you for your replying. But i had problem with std::toString and std::stoi when using ndk r9d
how to solve it?

Thanks it worked how can some body have such stupid error it waste my 2 days for building my project as I was thinking I am doing some error in building the project