Android Studio compilation documentation up to date?

Hi,

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.

I’ve checkout cocos 3.14 version, installed android studio using http://www.cocos2d-x.org/docs/installation/Android-Studio/ , and tried to run CppTests directly from AndroidStudio, as it’s advertised in that documentation page.

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) ??

Thanks,
Chris

The documentation is still correct. What’s your Android Studio version?

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 :slight_smile:

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).

For starter, the http://www.cocos2d-x.org/docs/installation/Android-terminal/index.html documentation is not up to date, since the “android” command is deprecated and some commands have even been removed from it).

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.

Oh, android studio native support is available since v3.15

Edit: in v3.13.1, you should build .so by command line, then use Android Studio to generate APK.

And if you use v3.15+, you can refer to this doc.

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’m sorry, but I still don’t see any 3.15 tag in the repository.
The closest I can find is cocos2d-x-3.15rc0

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.

I experienced a similar problem, but using NDK r14b solved it.
Manually download NDK r14b and replace “<ANDROID_SDK_ROOT>/ndk-bundle”.

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 :slight_smile:

Is there a clean way to tell Android Studio which ndk verison to use ?

Is that a configuration option to set in android studio for all projects, or is that a per-project option that is (or can be) set in cocos?

I’m not talking about the PATH where the ndk sits, I’ve found this option as ndk-dir, I’m talking about the VERSION of the ndk