I’m trying to update some old cocos2d-x projects to Android Studio (can’t use old Ant scripts anymore for various reasons), and I’m having a very hard time to set this up correctly. I’m using MacOS.
First of all, it looks like AS is not building the c++ part of libcocos2dx or CppTests, so when it’s run on a device/emulator, I’ve the classic findLibrary fatal error.
I even tried to create a new project using “cocos new”, same errors.
I’ve even tried to use command-line “cocos compile” but since the “android” command line is broken now, it’s not working.
So, what is going on?
Is the documentation page incomplete (by not saying we should compile the c++ part from console first), or is my android studio setup not valid (I have no error when compiling from AS, gradle is running fine without errors, the apk is generated, but without the .so obviously) ??
I don’t have access to my Mac right now, but since I had only the old adt-bundle installed, I downloaded a fresh version of AS (so I assume it’s the latest), and the latest NDK.
When I try to build, I’m pretty sure the c++ part is not build, since the build only takes about 4 seconds
Ok so, I did a fresh install on a Windows computer.
Studio 2.3.3 (latest)
Cocos 3.13.1 (not using 3.14 since it’s not in the http://www.cocos2d-x.org/docs/installation/A/index.html documentation, so I’m sure this version is compatible).
Now, I launch android studio and choose “Import project (Eclipse ADT, Gradle, etc…)”, even though I don’t understand why the documentation says to import, it looks like the “Open an existing Android Studio project” options is working as well.
When I hit the build button… it takes no more than a few seconds, which is impossible for it to build all the cpp files in such a time.
Of course, no error message!
What am I doing wrong… so tired loosing so much time on android platform. Even windows 10 is easier nowadays.
Hum my bad, I didn’t see the 3.15 tag in the repository so I took the latest one I had in July (3.14).
I’ll try again with 3.15.1 then, and keep you informed.
If there is a new up to date documentation, then the old one should have a link to it for 3.15.
I’ve checkout 4ca29ac1cfc0e0ce924829e99c859d3a0a26cf00 , which seems to be the closest commitID for 3.15.1
The good news, it takes more time to compile, so it looks like it’s really building cpp files now.
The bad news, it doesn’t fully compile, got 4 errors in ProcessCpuTracker.cpp, undefined ‘read’ ‘close’ ‘read’ ‘close’ symbols.
Thanks for your input, I’ll give it a try later today.
I was kind-of pissed that the android studio project made me re-download the ndk, although it was already installed in another path (and the NDK_ROOT variable was even correctly set, like said in the command-line documentation).
Too bad I have to even change the official (well… there is no tag in the repository, so it’s hard to say it’s official) build settings because it’s not building