An Phung
An Phung

Reputation: 409

Open cocos2d-x-3.7 in Android Studio

What is the proper way to open cocos2d-x-3.7 in Android Studio?

I tried:

  1. Open existing project in Android Studio project > Choose proj.android-studio directory (In another attempt, I also tried to choose the base directory MyGame)
  2. Run
  3. Error: couldn't find "libcocos2dcpp.so.

Moreover, it also does Classes directory in the Project.

Upvotes: 4

Views: 7204

Answers (3)

Nikita
Nikita

Reputation: 303

Error: couldn't find "libcocos2dcpp.so. For this you need to compile android studio project first so .so files and classes folder will be generated. Open your command line and enter the following command to compile your android studio project:

cocos compile -p android --android-studio --ap android-24 --app-abi x86

This will create required files in your proj.android-studio directory. Now import this project into Android Studio and try to run it.

Upvotes: 0

finalpets
finalpets

Reputation: 281

When you try to run the application on Android Studio, you get the error couldn't find "libcocos2dcpp.so" because it doesn't have the NDK for building your game.

I recommend you to compile proj.android and import that, cocos2d-x 3.7 doesn't support full Android Studio yet. Do this:

  1. cocos compile -p android

  2. Then import your proj.android to Android Studio.

  3. Now you can run your application but you won't able to debug it, bad news (it will just install the APK on your device or virtual device).

Hope it helps.

Upvotes: 0

Omniwheel
Omniwheel

Reputation: 111

Android Studio is only partially supported in cocos2d-x 3.7 and 3.8. With the default project you will only be able to run your app without debugging using Android Studio.

Prior to running your app in Android Studio you will have to compile using the Android Studio flag:

cocos compile -p android --android-studio

You will have to run this command after any changes to your app are made, since the default Android Studio currently doesn't compile your project.

Furthermore the default Android Studio project does not include the Classes directory.

Suggestion: Use Eclipse or Xcode to develop your cocos2d-x projects for now. Hopefully future versions of cocos2d-x will have better support for Android Studio out of the box, this is critical considering Google is dropping support for Eclipse.

Upvotes: 1

Related Questions