Help us with Android project setup


it will, there is a database issue, currently. There is a topic about this issue.


The database issue has been resolved.


Here’s my (so far unsuccessful) experience using the latest installation instructions while trying to install the current tools for a new C++ cocos2d-x 3.16 project using Android Studio v3.0.1. I’m using the same Mac with High Sierra that was used for making my last game, which used Terminal commands to build for Android. But since Terminal commands no longer work for building cocos2d-x for Android, I’m now switching to Android Studio.

I stumbled across several different errors trying to build and run CppTests. The instructions don’t tell you that you need to import “build.gradle” to load a project into Android Studio, but I remembered this from my previous attempts at building cocos2d-x in Android Studio in the past. (Hint: instructions for running CppTests should mention build.gradle). Anyway, after trying lots of different things and searching online for clues as to the causes of my CppTests building problems, I ultimately decided that the PATH and environment variables that I set up for my previous Terminal-based project in .bash_profile were probably interfering with the operation of Android Studio. I therefore commented out every line of .bash_profile. Then I rebooted, completely uninstalled Android Studio using instructions at, and installed a fresh copy. I also got a fresh copy of cocos2d-x.

So now that I had a “clean” environment to work with I proceeded to build and run CppTests using the emulator for a Nexus 6P with API 25. But it is still failing with errors that give no clear indication stating how to fix them. A popup box says: “Application Installation Failed: … Failed to Finalize Session: INSTALL_FAILED_NO MATCHING_ABIS: Failed to extract native libraries, res = -113.” And in the Messages Gradle Build window is a red-error-circle on the line that says: “Android NDK: Application targets deprecated ABI(s): armeabi”. See this screenshot.

Why does this happen with a clean build, and what do I do to fix it? And how can you improve the installation instructions so that others don’t stumble here as well? If you want to attract new users to Cocos2d-x, it is important to give clear directions on how to get started, so that they don’t get discouraged and decide to try out other multi-platform environments like Unity.

Thanks for taking a look at this!


The emulator ist not armeabi. So you need to add x86 to the target list or test on a real device.

See in

# List of CPU Archtexture to build that application with
# Available architextures (armeabi | armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86

the last line has to be at least



The Instructions work for me, I tested them not long ago. Let me run through them again.


Thanks for the tip, Mars3142! Now someone needs to update the the CppTests instructions to mention:

  • import the file named build.gradle
  • emulator uses x86, so update with the line: PROP_APP_ABI=armeabi-v7a:x86
    Then others won’t waste hours uninstalling, reinstalling, googling error messages, and generally trying to figure this out, like I have.


Can you try building a cocos new .. and tell me if it works for you would of the box?


This will give the same result because he uses an emulator.

and long ago


Testing CppTests as well as the new project created by “cocos new …” both work, once you install all the sdk versions that are needed (by default, I believe requires version 14 and some others). I found myself being diverted to various references in order to: a) know that controls the required SDKs, b) figure out which of the four SDK version numbers in I should override, and why, and c) what PROP_APP_ABI does, and how I should change it so that it doesn’t use the deprecated “armeabi” value.

I have been unsuccessful at getting the emulator work reliably even after changing PROP_APP_ABI to x86 – It occasionally works, but never twice in a row, even with a reboot in between. Running on actual Android devices seems to be more straightforward, and maybe should be suggested for users who are just beginning to set this up.

I’d like to repeat that the command-line tool instructions say that you need to run before cocos new, but is very picky about the format of the input the user provides. As I mentioned above before I started using Android Studio, “I had several false starts because wasn’t documented well here. Is a trailing slash required on the ANDROID_NDK_PATH and ANDROID_SDK_ROOT? (yes it is.) Do you need to specify the bin sub-directory for your ANT_ROOT directory? (yes you do.)” I don’t know which of these environment variables are absolutely necessary if you only need to run “cocos new …”. And it was not easy finding the paths to these components so that they point to the ones that were previously installed by Android Studio. Some suggestions along these lines would be helpful.

I’m glad there is an interest in improving these installation instructions. I love open source projects, but I have observed with several open source projects that volunteer contributors are frequently more interested in adding new features, than they are keeping the documentation for beginners up to date.


Thank you @doffen for your detailed replies. This process of building on Android has caused me many days of frustration. All of the documentation seems to be outdated and intermediates / beginners are left to piece together what they can.

I did get a Hello World to finally work on a device but after trying to integrate my iOS cocos2dx v3.16 code I could not rebuild. I tried starting again from scratch and could not get another Hello World to even build and run on Android.

It is unclear which combination of the many patch fixes I tried (downgrading my Java JDK, downgrading the NDK, updating, adjusting build.gradle, not downgrading gradle, etc.) need to be done to get it to work again. Multiple people have tried to talk me into just moving the game over to Unity. I am reaching out here in effort to stay with Cocos2dx.

Thank you to @slackmoehrle and the other authors for your invaluable time documenting and answering questions. It is unfortunate that as soon as you update something Google makes another meaningful change. If I find any clear, consistent solution I will reply an answer here.


Hello Everyone! Back from Vacation! Anything I can help with that hasn’t already been done?



Ok, I got my new cocos2dx Hello World project running on a device again. I think the heart of the issue had to do with Armeabi being deprecated.

I tried @mars3142 solution but it was not enough (at least for me). The errors initially go away but on the attempt to run the build it just goes on forever and never builds. I had to Clean Project before they would reveal:

Error:(81) Android NDK: Application targets deprecated ABI(s): armeabi

There is also a lot of outdated or inaccurate Android Studio feedback on StackOverFlow to resolve this (including a suggestion to delete and add a “task ndkClean(type: Delete) {...}” function to solve the error, which did not work for me either).

Here is what did work:

  • Open up
  • Add this code above the “LOCAL_MODULE” line (though its specific location does not matter): APP_ABI := arm64-v8a armeabi-v7a x86 x86_64 and re-save.

I ran it again and it worked. As stated above it is unclear if another minor tangential change, update, or downgrade also contributed. I would lean on the experts for updating documentation or providing feedback for this otherwise. Hope this helps you!


@zhangxm what do you currently need help with testing?


@slackmoehrle i think you can test latest github codes to check:

  • all tests works
  • new projects works

since in the latest github codes, it uses clang+libc++, remove eclipse projects, remove armeabi, uses NDK r16+.


@zhangxm sounds like fun! I’ll start this today and update this thread.

Community members, let 's help @zhangxm out with this testing too, please.


@zhangxm a few things I am noticing

  1. cocos new output shows errors. bug?
$ cocos new MyAndroidTest -p -l cpp -d .
Python 2.7.10
> Copy template into /Users/dubb/MyAndroidTest
> Copying Cocos2d-x files...
> Rename project name from 'HelloCpp' to 'MyAndroidTest'
> Replace the project name from 'HelloCpp' to 'MyAndroidTest'
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
> Replace the project package name from 'org.cocos2dx.hellocpp' to ''
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
/Users/dubb/MyAndroidTest/ is not found.
> Replace the Mac bundle id from 'org.cocos2dx.hellocpp' to ''
> Replace the iOS bundle id from 'org.cocos2dx.hellocpp' to ''
  1. Working with Android Studio after running Cocos new was delightful. I tried running my project and I didn’t have everything that was required installed. Android Studio walked me through what I was missing and my project built fine.

  2. running my project wasn’t so simple. It never runs for me on my Vivo X20:

01/11 17:49:57: Launching HelloCpp
$ adb install-multiple -r -t /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ 
Error while Installing APKs

But, on my Nexus 9 tablet it installs and runs fine.

Edit: I love the fact that Android Studio has a terminal window built in.



I fixed it in, and will update cocos2d-x’s sub module reference now.

I don’t know why your adb try to install so many APKs, what did you do?

 $ adb install-multiple -r -t /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ /Users/dubb/MyAndroidTest/ 


This seems to be because of activated instant run. I would suggest to deactivate it, because I have more problems than help of that. And hot swap of code is mainly a feature for Java/Kotlin only projects, but we use native code and so we can’t have real benefits, I think.

@mozartalouis What’s your opinion on instant run? Use or don’t use?


We probably shouldn’t use it. I wouldn’t work.

As you said, since were using native code, instant run give no benefits. The .so would be reloaded every time and in most cases, Android Studio will just run a full build anyways.


@mars3142 @mozartalouis good to know, thanks. @slackmoehrle may be we should mention it in the docs?