Your c++ files should be under TestGame/cpp/MyGame/TestGame/Classes.
To debug, just set a breakpoint (Ctrl+F8) and start debugging (button with play arrow over a bug).
Set ABI in graddle.properties (i.e x86 if you will be running the app in the emulator). Also uncoment the line org.gradle.jvmargs in the same file to speed up gradle.
Android studio 2.3: you have to use ndk-r13b because of a bug in Android Studio. So you replace ndk-bundle dir (it’s under your sdk dir) with the contents of ndk-13b.
Note that if you previously used the buggy version of Android Studio it’s best to create a new project (using cocos new)… it seems some previously generated build files under your project directory cause problems.
Just followed Effolkronium Steps, used NDK-r13b like samo_dadela wrote and updated Android.mk like Effolkronium did! Works so far…! I can Build, edit and launch app from Android Studio. BUT…
I noticed a strange behaviour… I can install APK just once. After editing code the APK installation fails with the error message “java.io.IOException: Connection was closed from Remotehost… Error while Installing APK”.
In the “Android Monitor” Window I can see that the connected Device goes offline while installing APK!
EDIT:
Only solution for now is to restart ADB manually.
Maybe it’s because of Android Studio. I don’t know.
I’ve unistalled it. cleaned up. updated java, ant etc. installed Android Studio 2.3 after reboot. same result. Tried it with Android Studio 2.4 Preview but no success!
I’m new to Android Studio with NDK! Maybe I’m doing something wrong. I don’t know. (Just follwed the steps above)
Android Studio still installs my other Java Apps. For now this is my Result.
Heads up:
Spent some time with Android Studio 2.4 Preview 3 - this is really beta quality, crashes a lot.
The alternative is to use AS 2.3 with ndk-r13b.
That is so weird. it was a issue of my USB-Cable. Android Studio seems to dislike my USB-Cable
The Cable works fine with Eclipse, xCode even VisualStudio on Windows… but not with Android Studio.
A few day ago I bought a new USB-Cable and it works flawless. I can compile and run my Games without any problems (everytime). Thanks @zhangxm.
that why it didnt worked - u replaced cocos2d folder inside it located new build.gradle for cocos2dx core where was changed little syntax for TARGET_SDK before it was like TARGET_SDK: 22 and in 3.15 it is TARGET_SDK: PROP_TARGET_SDK_VERSION.
PROP_TARGET_SDK_VERSION definition is located in android-studio project folder , but as u using old version u missing this setup there - so create new project in 3.15 open it in android studio and check gradle config files what was changed there or manually change in cocos2d folder that gradle file to old one where is not used this variable - or just replace it by number.
I created Sample game using Cocos2dx 3.15 and it’s running fine in studio. I’m able to compile, run and debug as well. But my problem is after I copied all my classes, resources from my other project (it’s running fine another system) and updated Android.mk file according to that. Now I’m not able to build from Android Studio. and in External Build Files Application.mk file also not showing.