Cosos2d-X Build Android X86 Errors? - android

When I run the command
cocos compile -p android --ap android-15 --app-abi x86
I get the error
/audio/android/cutils/bitops.h: In function 'int bitmask_ffz(unsigned int*, int)':
/audio/android/cutils/bitops.h:65:30: error: 'ffs' was not declared in this scope
bit = ffs(~bitmask[i]);
^
[x86] Compile++ : audioengine_static <= AudioDecoderProvider.cpp
make: ** [obj/local/x86/objs-debug/audioengine_static/AudioDecoder.o] Error 1
make: ** Waiting for unfinished jobs....
make: Leaving directory `/DeneOyun/proj.android'
**Error running command, return code: 2.**

You probably upgraded NDK to version 15.
Add the following to your Android.mk:
APP_DEPRECATED_HEADERS := true
for more details: link

Related

android project build with ndk is failing due to permission denied error

I bought a new laptop (preinstalled with macOS Catalina) and i'm setting up an existing android project, and installed the same version of ndk and kept all the settings same.
I tried to build the project, then got couple of macOS catalina security prompts related to clang and other ndk binaries, resolved all of them.
Then did a clean build and got this error.
Error while executing process /Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/eshwar/workspace/project/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk NDK_APPLICATION_MK=/Users/eshwar/workspace/project/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk APP_ABI=arm64-v8a NDK_ALL_ABIS=arm64-v8a NDK_DEBUG=1 APP_PLATFORM=android-21 NDK_OUT=/Users/eshwar/workspace/project/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/Users/eshwar/workspace/project/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/lib NDK_TOOLCHAIN_VERSION=clang -j16 NDK_DEBUG=1 /Users/eshwar/workspace/project/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/arm64-v8a/libcocos2djs.so}
[arm64-v8a] Compile++ : cocos2djs_shared <= AppDelegate.cpp
make: execvp: /Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++: Permission denied
make: *** [/Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/build/core/build-binary.mk:478: /Users/eshwar/workspace/project/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/arm64-v8a/objs-debug/cocos2djs_shared/__/__/__/Classes/AppDelegate.o] Error 127
Tried couple of times and got errors in different files.
Tried:
reinstalling NDK
trying different version of NDK
chmod -755 on the entire ndk folder
None of them succeeded.
Then wanted to check if the issue is related to my laptop or the project. So, installed a ndk sample project and tried to build, it worked successfully.
$ /Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/Android.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/build/intermediates/ndkBuild/arm7Debug/obj NDK_LIBS_OUT=/Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/build/intermediates/ndkBuild/arm7Debug/lib hello-neon
[armeabi-v7a] Compile thumb : hello-neon <= helloneon.c
[armeabi-v7a] Compile thumb : hello-neon <= helloneon-intrinsics.c
[armeabi-v7a] Compile thumb : cpufeatures <= cpu-features.c
[armeabi-v7a] StaticLibrary : libcpufeatures.a
[armeabi-v7a] SharedLibrary : libhello-neon.so
then checked the ndk-build command in sample project, it didn't have the -j16 flag when it was getting built. Then manually added -j16 flag to the sample project and got the same error.
$ /Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/Android.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/build/intermediates/ndkBuild/arm7Debug/obj NDK_LIBS_OUT=/Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/build/intermediates/ndkBuild/arm7Debug/lib -j16 hello-neon
[armeabi-v7a] Compile thumb : hello-neon <= helloneon.c
make: execvp: /Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang: Permission denied
make: *** [/Users/eshwar/Library/Android/sdk/ndk/21.2.6472646/build/core/build-binary.mk:476: /Users/eshwar/workspace/ndk-samples/other-builds/ndkbuild/hello-neon/app/build/intermediates/ndkBuild/arm7Debug/obj/local/armeabi-v7a/objs-debug/hello-neon//Users/eshwar/workspace/ndk-samples/hello-neon/app/src/main/cpp/helloneon.o] Error 127
make: *** Waiting for unfinished jobs....
[armeabi-v7a] StaticLibrary : libcpufeatures.a
[armeabi-v7a] Compile thumb : hello-neon <= helloneon-intrinsics.c
Then manually run the ndk-build of my project without -j16 and its building.
FYI: my old laptop(updated to macOS Catalina) works fine with -j16 flag
What is the significance of -j16 flag. How do I know from where its is getting added and how to remove it.
edit: found using the ndk help
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
Tried with multiple j values. It fails with anything more than 2 on a 8 core processor. Is there any settings which controls this?

Undefined reference to 'jniRegisterNativeMethods' Android NDK

I'm trying to build the .so file from available NDK project. But I encounter the
undefined reference to 'jniRegisterNativeMethods' error when I try to compile the code using cmd with ndk-build
Here I'm posting the block of that execution
Android NDK: WARNING:jni/Android.mk:gba: non-system libraries in linker flags: -lnativehelper
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi] Compile++ arm : gba <= emulator.cpp
[armeabi] SharedLibrary : libgba.so
C:/sdk/android-ndk-r10e-windows-x86_64/android-ndk-r10e/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld.exe: error: cannot find -lnativehelper
jni/gbalib/nativehelper/JNIHelp.h:108: error: undefined reference to 'jniRegisterNativeMethods'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libgba.so] Error 1
E:\Android-Projects-Archieve\Library-Archives\gameboid>
I expect it to build an .so file called libgba.so Let me know in the comments if you need more info to look into this issue. Thanks in advance.

Flac Extension for Exoplayer

I am trying to compile flac extensions to use with Android Studio, ExoPlayer in my project. I tried following the instructions in the ExoPlayer README however, I get the following error:
cd ExoPlayer
EXOPLAYER_ROOT="$(pwd)"
FLAC_EXT_PATH="${EXOPLAYER_ROOT}/extensions/flac/src/main"
NDK_PATH="~/Downloads/android-ndk-r17c"
cd "${FLAC_EXT_PATH}/jni"
mv ~/Downloads/flac-1.3.2 flac
${NDK_PATH}/ndk-build APP_ABI=all -j4
...:~/Downloads/ExoPlayer/extensions/flac/src/main/jni$
NDK_PATH=.../Downloads/android-ndk-r17c
...:~/Downloads/ExoPlayer/extensions/flac/src/main/jni$ ${NDK_PATH}/ndk-build APP_ABI=all -j4
Android NDK: WARNING: APP_PLATFORM android-14 is higher than android:minSdkVersion 1 in .../Downloads/ExoPlayer/extensions/flac/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android-14. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.
Android NDK: WARNING: APP_STL gnustl_static is deprecated and will be removed in the next release. Please switch to either c++_static or c++_shared. See https://developer.android.com/ndk/guides/cpp-support.html for more information.
[arm64-v8a] Compile : flacJNI <= format.c
[arm64-v8a] Compile : flacJNI <= stream_encoder_framing.c
[arm64-v8a] Compile : flacJNI <= stream_encoder_intrin_avx2.c
[arm64-v8a] Compile : flacJNI <= stream_encoder_intrin_sse2.c
[arm64-v8a] Compile : flacJNI <= stream_encoder_intrin_ssse3.c
[arm64-v8a] Compile : flacJNI <= window.c
.../Downloads/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/format.c:47:45: error:
use of undeclared identifier 'VERSION'
FLAC_API const char *FLAC__VERSION_STRING = VERSION;
^
.../Downloads/ExoPlayer/extensions/flac/src/main/jni/flac/src/libFLAC/format.c:49:64: error:
expected ';' after top level declarator
FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " VERSION ...
^
;
2 errors generated.
make: *** [/home/philip/Downloads/ExoPlayer/extensions/flac/src/main/obj/local/arm64-v8a/objs/flacJNI/flac/src/libFLAC/format.o] Error 1
make: *** Waiting for unfinished jobs....
How do I get this to work? Thanks.
To get the flac extensions to compile in Android Studio I needed to go to:
Tools | SDKManager | SDKTools and checked Cmake

android build error on ubuntu 11.10

I am facing a problem when trying to build android 2.3 on ubuntu 11.10
First error -
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: * [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1
make: * Waiting for unfinished jobs....
I solved this by modifying,
frameworks/base/libs/utils/Android.mk
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
But after doing the above modification, new error came up,
host SharedLib: libneo_cgi (out/host/linux-x86/obj/lib/libneo_cgi.so)
host C++: libutils <= frameworks/base/libs/utils/Asset.cpp
host C++: libutils <= frameworks/base/libs/utils/AssetDir.cpp
host C++: libutils <= frameworks/base/libs/utils/AssetManager.cpp
g++: error: unrecognized option ‘--fpermissive’
make: * [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/Asset.o] Error 1
make: * Waiting for unfinished jobs....
g++: error: unrecognized option ‘--fpermissive’
g++: error: unrecognized option ‘--fpermissive’
make: * [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetDir.o] Error 1
make: * [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o]
Build Configuration:
Ubuntu 11.10
Tried with both gcc versions, 4.4 and 4.6
but nothing is working out, please help me out struggling from the past one day
Command options used to built,
$. build/envsetup.sh
$lunch 1
$make -j4
GCC - version
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6.1/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
----------------------------------------------------------------
EDIT 2-
I think its a problem with the gcc version, not its moving at a better pace, but now i am getting this error-
cmd - make CC=gcc-4.4 CXX=g++-4.4
error - host SharedLib: libneo_cgi (out/host/linux-x86/obj/lib/libneo_cgi.so)
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_cgi.so] Error 1
I have tried this solution and it solved the problem you mention: How to fix problem of incompatibility between GCC 4.6 and Android 2.3 (Gingerbread).
However, I cannot link after all is compiled.
I am compiling 2.2 with gcc-4.6 on linux mint.
Anyway it should help you.

Android.mk file for Executable: accRuntimeTest

Can you please tell me where I can find the Android.mk file for Executable: accRuntimeTest?
I am getting the following error when I compile android source on ubuntu 9.10. I think it misses a linker flag to link a library 'dlsym', I just don't know where is the Android.mk file I should go and fix it?
Install: out/target/product/generic/system/usr/keychars/qwerty.kcm.bin
Install: out/target/product/generic/system/usr/keychars/qwerty2.kcm.bin
Install: out/target/product/generic/system/usr/keychars/tuttle2.kcm.bin
Copy: out/target/product/generic/system/etc/apns-conf.xml
host Executable: accRuntimeTest (out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/accRuntimeTest)
host Executable: acc (out/host/linux-x86/obj/EXECUTABLES/acc_intermediates/acc)
/usr/bin/ld: out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/runtimeTest.o: in function symbolLookup(void*, char const*):system/core/libacc/tests/runtimeTest.cpp:66: error: undefined reference to 'dlsym'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/accRuntimeTest] Error 1
make: *** Waiting for unfinished jobs....
Android.mk is Android's own Makefile and your error seems to due to compiler dependent.
Try compiling your source in text mode in your PC.

Categories

Resources