After a whole day of experimenting, I managed to get this working in Windows. Don’t know if this is still helpful to you but here’s the tweaks I had to make to piottros’ steps above (also I precompiled the libs using --app-abi armeabi:x86 to support both arm and x86):
Step 5:
Make sure you use a relative path to the libcocos2dx directory in settings.gradle e.g. ../../../../frameworks/cocos2d-x-3.14.1/cocos/platform/android/libcocos2dx
Step 6:
colon : characters such as in C:\ break the NDK_MODULE_PATH parameter on Windows, so you need to change them for semicolons ; if you’re using an absolute path for the “cocospath” string. Those lines in my build.gradle file look like this: cocospath = "C:/users/dev/code/frameworks/cocos2d-x-3.14.1" arguments "NDK_MODULE_PATH=$cocospath;$cocospath/cocos;$cocospath/external;$cocospath/cocos/prebuilt-mk;$cocospath/extensions"
It looks as though the cocos2d-x dev team are already fixing this path issue for the next release though
@piotrros, I think the main problem is that I don’t know what I am doing in Android Studio (& also Cocos2d-x and SDK BOX) my first project and I am struggling…
Open the project.android-studio and I can build and run but not ‘see’ or ‘debug’ my C++ files, Android view:
It depends which android studio version and cocos version u using, debug in cocos by default enabled only in 3.15 branch and for it you need newest android studio
@energyy, thanks for the points made but some people (see @piotrros below) report being able to use AS with cocos 3.14.x. I would like to achieve this, v.much!
@piotrros, thanks for coming back. What I did:
Downloaded & unzipped your ‘template’ project.
Changed ndk to 13b.
Installed required android sdks and build tools version.
Ran => cocos gen-libs -p android --ap android-10 (ok)
Updated pros.android-studio/settings.gradle
//project(‘:libcocos2dx’).projectDir = new File(‘/Users/piotr/Documents/pierdoly/cocos2d-x-3.14/cocos/platform/android/libcocos2dx’)
replace with
project(‘:libcocos2dx’).projectDir = new File(‘/Users/NF/SDK/cocos2d-x-3.14.1/cocos/platform/android/libcocos2dx’)
Updated proj.android-studio/app/build.gradle
//arguments “NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk:$cocospath/extensions”
replace with
arguments “NDK_MODULE_PATH=$COCOS_X_ROOT:$COCOS_X_ROOT/cocos:$COCOS_X_ROOT/external:$COCOS_X_ROOT/cocos/prebuilt-mk:$COCOS_X_ROOT/extensions”
@piotrros, still no luck. As you said my NDK_MODULE_PATH is not taking effect and I am still unable to build your ProjectName temple project.
I have tried changing the build.gradle file NDK_MODULE_PATH section every way. Single v double quotes. $COCOS_X_ROOT v local cocospath variable v hard coded paths. ‘:’ v ‘;’ path separators. Commenting out the line in the build.gradle file
//arguments "NDK_MODULE_PATH=$cocospath:…
shows no effect and I get the same error?? Sorry to ask again - Any idea? I will ask the community in a separate topic.
Hi there again
I’m currently trying to compile my project with FMOD. I’m really don’t understand how to use it with android… on iOS all simple as usually, integrated it in no time… Damn android, really crap ideology of everything from design to development process. Anyway…
While iOS integration I just placed FMOD into /Classes/FMOD, so it’s not in cocos2d/external/fmod… and cocos2d-x is not a place where I want to store it. I want to save it in my project.
My cocos2d-x folder for all projects located at /Volumes/MacData/Cocos2d-x
Current project located at: /Volumes/MacData/GitProjects/ProjectName
Structure of FMOD is: /Volumes/MacData/GitProjects/ProjectName/Classes/FMOD
here is what inside FMOD folder:
/iOS/
/Mac/
/android/Android.mk
/android/api/lowlevel/inc/ - header filles here
/android/api/lowlevel/lib/ - libs files here
I tried to edit Android.mk at JNI folder as per your recommendation but with my folders paths and here it is:
Build command failed.
......
Android NDK: /Volumes/MacData/Cocos2d-x/external/flatbuffers/Android.mk:
Cannot find module with tag
'/Volumes/MacData/Cocos2d-x/external/flatbuffers/../../../Classes/FMOD/android'
in import path Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
I think it is bad place for Fmod as u including into android or ios build other platfrom files.
That compile error ussualy comes when Android,mk format is incorrect, like space or something added or wrong $(call import-add-path) also its not clear what in your Android.mk for FMDO where libs files located…