Best tools to use for developing cocos2d-x android game

Hi,

I am new here and trying to start developing android games with cocos2d-x. I have been lurking around this forum for few days now trying to figure out what to tool I need to use to kick start developing an android game.

I started first trying to configure cocos2d-x 3.16 on visual studio with 2015 with update 3. I quickly learned it wasn’t working, went and read installation guides and noticed that I needed to use v 3.13.1 and a special template. Didn’t have much luck their either. So I decided to look for other alternatives.

My next alternative was using android studio, I installed it and I was able to run cpptest on my device (samsung S8). Couldn’t run that same project on the default emulator because it kept crashing at start.

Next I tried to run a helloWolrd sample and I got the same problem of app crashing at start on both device and emulator.
The thing is that I am a total beginner when it comes to android development I have no past experience developing apps in android.

So my questions are:
Is android-studio currently the best way to use for cocos2d-x using C++? I read somewhere in this forum that I can setup gradle so I don’t need to use command-line compile code, what setting should that be? I also noticed that android studio does a lot of downloading when on the first start and it did almost everything automatically to get cpptest to work, but is there a preferred setting? any API that isn’t supported yet?
Would be nice if there is a detailed instructions on how to start a helloWorld project and the best way to modify the C++ code in android.

Is there a better IDE to use for android that can support latest android API?

Is there thing I better try to learn before developing C++ android games with cocos2d-x? like may be developing C++ android apps with android-studio?

Thanks in advance

I will start with my experience with android-studio till now.
I have android-studio 2.3.3 (latest) installed with latest NDK 15.2.4203891
Cocos2d-x version 3.16
ANT v 1.10.1 (Latest)

So just now I Build apk for CppTest by loading proj.android-studio into android-studio. In gradle console it asked me for few things to download (CMAKE and few other things). I downloaded all that it asked and the build was successful. I tried the app on my phone and it worked.

Next, I wanted to start a new cocos2d-x project. So I used
cocos new MyGame3 -l cpp -p com.MyApps.MyGame3
this created standard HelloWorld project called MyGame3 folder inside MyApps.
I loaded proj.android-studio then tried to build apk but got the following errors:

Information:Gradle tasks [:MyGame3:assembleDebug, :libcocos2dx:assembleDebug]
C:\Users\Owner\AppData\Local\Android\cocos2d-x-3.16\MyApps\MyGame3\Classes\AppDelegate.cpp
Error:(127, 1) opening dependency file C:/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/MyGame_shared/C_/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/jni/__/__/__/Classes/AppDelegate.o.d: No such file or directory
Error:(127, 1) fatal error: opening dependency file C:/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/MyGame_shared/C_/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/jni/__/__/__/Classes/AppDelegate.o.d: No such file or directory
C:\Users\Owner\AppData\Local\Android\cocos2d-x-3.16\MyApps\MyGame3\proj.android-studio\app\jni\hellocpp\main.cpp
Error:(18, 1) opening dependency file C:/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/MyGame_shared/C_/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/jni/hellocpp/main.o.d: No such file or directory
Error:(18, 1) fatal error: opening dependency file C:/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/MyGame_shared/C_/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/jni/hellocpp/main.o.d: No such file or directory
C:\Users\Owner\AppData\Local\Android\cocos2d-x-3.16\MyApps\MyGame3\Classes\HelloWorldScene.cpp
Error:(113, 1) opening dependency file C:/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/MyGame_shared/C_/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/jni/__/__/__/Classes/HelloWorldScene.o.d: No such file or directory
Error:(113, 1) fatal error: opening dependency file C:/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/MyGame_shared/C_/Users/Owner/AppData/Local/Android/cocos2d-x-3.16/MyApps/MyGame3/proj.android-studio/app/jni/__/__/__/Classes/HelloWorldScene.o.d: No such file or directory
Information:BUILD FAILED
Information:Total time: 2 mins 54.229 secs
Information:6 errors
Information:0 warnings
Information:See complete output in console

Any idea on how to fix this? I’m thinking there might be something wrong with the template used in new projects, but I have now idea how to fix it

I solved this problem, it is not related to cocos2d-x at all, the path was too long…
It seems this problem is the cause of many issues posted here on this forum concerning android-studio
May be it is good to point this out in android-studio guide

I’ve stumbled upon the same issue, and mavios suggestion/solution really worked.
I had my project apparently placed too deep in folder structure. Could someone explain what is the issue behind it and how to fix it?

I’m using Win10, AndroidStudio 3.0.1, cocos2d-x-3.16, buildToolsVersion 25.0.2, jdk1.8.0_151.

Additionally I had also issues with none existing packages:
error: package android.annotation does not exist -> SuppressLint class in …\java\src\org\cocos2dx\lib\Cocos2dxWebView.java
error: package android.annotation does not exist -> TargetApi class in …\java\src\org\cocos2dx\lib\Cocos2dxWebViewHelper.java

I’ve commented out those two imports and moved the whole project to root folder and then it worked.