I’m starting to create my own projects on Android. I’m having a bit of trouble compiling my project.
Cocos2d-x 3.14.1
using the pre-built libraries.
Here is my error:
Android NDK: /Users/slackmoehrle/Projects/cocos2d-x/cocos/audio/android/prebuilt-mk/Android.mk: Cannot find module with tag 'android-specific/tremolo/prebuilt-mk' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
/Users/slackmoehrle/Projects/cocos2d-x/cocos/audio/android/prebuilt-mk/Android.mk:36: *** Android NDK: Aborting. . Stop.
Error running command, return code: 2.
I’m working to write some docs on using pre-builts more and integrating them into YOUR applications, not just starting a project with cocos new. Right now, I cannot seem to compile a project with pre-builts.
@slackmoehrle
Are you using version 3.14.1? I just asked @dumganhar, the library tremolo is added to the v3 branch of cocos2d-x. But not in the version 3.14.1.
It’s a problem of command cocos gen-libs. I’ll fix it in v3 branch later.
Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml
Android NDK: Trying to define local module 'audioengine_static' in /Users/slackmoehrle/Projects/cocos2d-x/cocos/audio/android/Android.mk.
Android NDK: But this module was already defined by /Users/slackmoehrle/Projects/cocos2d-x/cocos/audio/android/prebuilt-mk/Android.mk.
/usr/local/Cellar/android-ndk/r13b/build/core/build-module.mk:34: *** Android NDK: Aborting. . Stop.
Error running command, return code: 2.
I found that you’re linking the module audio/android in your Android.mk. It’s the reason of your problem.
The module audio/android has already linked in the cocos/Android.mk.
When you’re using binary libraries of engine, the cocos/prebuilt-mk/Android.mk will be used ( instead of cocos/Android.mk). It will be using audio/android/prebuilt-mk/Android.mk.
Then there will be conflict with the audio/android/Android.mk configured in the Android.mk of your project.
Also, I think the following configurations in your project’s Android.mk will cause similar problems:
cocos gen-libs will generate the binary libraries & the corresponding Android.mk for each source code module. Because the Android.mk is different between source code & prebuilt libraries. (The prebuilt Android.mk will be gerenated in folder prebuilt-mk).
The project should link the prebuilt Android.mk to use the binary libraries of engine.
If you mixed prebuilt Android.mk & the source code Android.mk in the Android.mk of your project. The problem you mentioned will be occurred.
@slackmoehrle could you please me a bit please? I’ve already been struggling for like 2 days. So I’m also working with prebuilt libs, everything was working as expected on cocos2d-x-3.14 but when I updated to cocos2d-x-3.14.1 and I try to compile a Hello World application I get this error and I really couldn’t figure it out:
[armeabi] SharedLibrary : libMyGame.so
/Users/anieduard/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: /Users/anieduard/cocos2d-x-3.14.1/external/flatbuffers/prebuilt-mk/../../../prebuilt/android/armeabi/flatbuffers.a(flathash.o): multiple definition of 'main'
/Users/anieduard/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: /Users/anieduard/cocos2d-x-3.14.1/external/flatbuffers/prebuilt-mk/../../../prebuilt/android/armeabi/flatbuffers.a(flatc.o): previous definition here
/Users/anieduard/cocos2d-x-3.14.1/external/flatbuffers/prebuilt-mk/../../../prebuilt/android/armeabi/flatbuffers.a(flatc.o):flatc.cpp:generators: error: undefined reference to 'flatbuffers::GenerateCppGRPC(flatbuffers::Parser const&, std::string const&, std::string const&)'
/Users/anieduard/cocos2d-x-3.14.1/external/flatbuffers/prebuilt-mk/../../../prebuilt/android/armeabi/flatbuffers.a(flatc.o):flatc.cpp:generators: error: undefined reference to 'flatbuffers::GenerateGoGRPC(flatbuffers::Parser const&, std::string const&, std::string const&)'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libMyGame.so] Error 1
make: Leaving directory `/Users/anieduard/Desktop/MyGame/proj.android-studio/app'
Error running command, return code: 2.