How to add C++ folder to android stodio

I’ve imported a cocos2d-x to my android studio IDE, but it only has android code. Now I want to add Class folder(which contain C++ files) to android studio, because I have to implement on both Java and C++ code. So how can I do?

So, you get project.android and imported it to Android Studio? Its not very good. In new cocos templates there is a folder “project.android-studio” with template for android studio project and gradle support. In this template Android Stusio doesnt build c++ code, so you have to use cocos-console to build project(after c++ built you can use Android Studio to edit and deploy Java):

cocos compile -p android --android-studio

Note: There are no official way to edit C++ in Android Studio now. Its only experimental support of C++. Android studio template still uses old ndk-build with mk files.

1 Like

Thanks a ton for your answer. I’m a newbie and have no experience with cocos2d-x. I check my cocos project but cannot find project.android-studio folder :frowning:

I believe it’s because cocos not officially support Android Studio yet. If you downloaded Cocos2d-x from Cocos Store there are no “project.android-studio” folder. But you can download cocos from site and get this folder from there. Add it to your project.

Also check:

1 Like

Any problem if I download and add project.android-studio to my on-doing project?

You have to copy your java code, manifest and others to project.android-studio folder.
Then you can switch. Use this commands:

  1. cocos compile -p android
    To build “project.android” folder with eclipse(ant) project.

  2. cocos compile -p android --android-studio
    To build “project.android-studio” folder and Android Studio(gradle) project

1 Like

Cool, thank you so much,I will try this.

Hi @Gaspar, I downloaded cocos2d-x 2.2.6 on the cocos site but still have no project.android-studio folder

Oh, i am using cocos2d-x v3 and i dont think that cocos v2 support Android Studio. You can try to use project.android-studio from cocos v3 and use console to build c++, then use Android studio to make apk. But i am not sure that it will be easy

1 Like

if you are interested, I am trying to build c++ files in android-studio using gradle experimental plugin, check this topic for further information.

1 Like

Thank you so much!

thank you, but when I imported this project into android studio, it has no gradle file…

Hi…i wants to add new cpp files in my cocos2d-x projects in android studio.For that there was one step to run Build_native.py file in cmd but i am unable to find Build_native.py file in android project directory,it is missing.

i created new project but still Build_native.py is not generating(show hidden files is enabled).i alter the version of NDK from 14-15 and Re-creat new project but still Build_native.py is missing…I am newbie at coocos so any help will be very appreciate…