Update: We need help testing v3.17 (it's only a few weeks away)

Update: We need help testing v3.17 (it's only a few weeks away)


I checked and cocos gen-libs does not work me. It fails on Windows/Linux/Mac. The same command worked before.
Could you provide example how to use it?

Please see error:

/usr/bin/python -u /home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a --agreement n

<-------------> 0% WAITINGMove apk to /home/travis/build/mariusz102102/cocos2d-x/tests/cpp-empty-test/bin/debug/android
Build succeed.
Traceback (most recent call last):
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py”, line 1072, in
run_plugin(command, argv, plugins)
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py”, line 961, in run_plugin
plugin.run(argv, dependencies_objects)
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/plugins/plugin_generate/gen_libs.py”, line 79, in run
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/plugins/plugin_generate/gen_libs.py”, line 176, in compile
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/plugins/plugin_generate/gen_libs.py”, line 368, in compile_android
cocos.copy_files_with_config(copy_cfg, obj_dir, android_out_dir)
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py”, line 799, in copy_files_with_config
src_dir, src_dir, dst_dir, include_rules, exclude_rules)
File “/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py”, line 818, in copy_files_with_rules
for name in os.listdir(src):
OSError: [Errno 2] No such file or directory: ‘/home/travis/build/mariusz102102/cocos2d-x/tests/cpp-empty-test/proj.android/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a’
Traceback (most recent call last):
File “/home/travis/build/mariusz102102/cocos2d-x/tools/travis-scripts/…/…/build_android.py”, line 155, in
File “/home/travis/build/mariusz102102/cocos2d-x/tools/travis-scripts/…/…/build_android.py”, line 151, in main
File “/home/travis/build/mariusz102102/cocos2d-x/tools/travis-scripts/…/…/build_android.py”, line 142, in build
File “/home/travis/build/mariusz102102/cocos2d-x/tools/travis-scripts/…/…/build_android.py”, line 20, in run
File “/usr/lib/python2.7/subprocess.py”, line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[’/usr/bin/python’, ‘-u’, ‘/home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py’, ‘gen-libs’, ‘-p’, ‘android’, ‘-m’, ‘release’, ‘–ap’, ‘android-15’, ‘–app-abi’, ‘armeabi-v7a’, ‘–agreement’, ‘n’]’ returned non-zero exit status 1


I create with cocos new -p org.mars3142.template -l cpp CocosTemplate a new project.

After that, I changed into CocosTemplate/proj.android and ./gradlew build (on macOS).

–> Warning: Exception while processing task java.io.IOException: proguard.ParseException: Unexpected keyword ‘com.huawei.android.**’ in line 24 of file ‘/Users/…/CocosTemplate/proj.android/app/proguard-rules.pro’
—> there is a missing class

After fixing that, I got
–> Fix the issues identified by lint, or add the following to your build script to proceed with errors:

android {
lintOptions {
abortOnError false
—> It’s because of the AndroidManifest.xml from the app. Move line 31 before line 8.
—> Also add to AndroidManifest.xml (in libcocos2dx and libcocos2dx-with-controller) the permission < uses-permission android:name=“android.permission.VIBRATE” /> (without space before uses-permission)

Now I’m able to compile without any errors. Do you need a pull request for that?

PS: I didn’t check the others lint messages yet.


Thanks for the detail information. What NDK version did you use? I haven’t met lint error before. And yep, please send a PR for it.

@drelaptop please help to confirm the issue too. Thanks.


Firstly: test using command ./gradlew build, error occurs

Warning: Exception while processing task java.io.IOException: proguard.ParseException: Unexpected keyword 'com.huawei.android.**' in line 24 of file '/Users/laptop/CocosTemplate2/proj.android/app/proguard-rules.pro'

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':HelloCpp:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

Importantly, the same project runs on android studio, everything works well, I didn’t know clearly about the difference between ./gradlew build and build by android studio. @zhangxm @mars3142


Ehhm… sorry what?


./gradlew build is more specific and also runs lint. The build (run in Android Studio) only builds for the chosen device. If you call the Build APK from the menu it should do the same than the command line - Didn’t checked it. I prefer the command line, because it shows more detailed messages. - Your message is the same I described earlier (incl. the solution).

@zhangxm The lint messages don’t dependent on the NDK version (mine is 16.1.4479499 - latest available), it dependents on the build tools. And this is defined in your sample project. Weird, that you don’t see these messages. - Sure, I create a PR later.



I think that we should extend our appveyor, Travis Ci and add there more build configuration for android.

Below my python script to setup android environment for Linux/Mac/windows:

Currently I see two big android problems:

  1. “gradlew build” fails (I have to use assemblyDebug)
  2. “cocos gen-libs” fails for android

You can see 4 android builds.

  1. Cpp-test
  2. Cpp-empty
  3. Cocos new, build new ptoject
  4. Cocos gen-libs

Below sample setup that above script works on Linux/Mac/windows:

I think that such script can be even added to docs as recommended way of android setup.



I’ve created a pull request with my fixes. It should be green, if the CI work will be done. I would recommend to merge it into the release before 3.17 will be final.

If you confirm it, I would like to look into more lint messages, so the report will be more warnings free for the Android build.

@CrazyHappyGame Feel free to test my pull request in your CI system and report, if it works.


cocos gen-libs -p=android --app-abi armeabi-v7a x86

What command did you use?

@mars3142 thanks, i will take a look.

  • v3 branch
  • ndk r16
  • cocos console 2.3
  • sdk 27
  • sdk tool 27.0.1
    run: cocos compile -p android -m release -s xxxx , error:not found “libs” . After add the “lib” folder to “app” dir, compile passed.
    My game is so easy to crash that I don’t have time to find the cause. Not on ios.C9E0CDA8-8548-42B7-9B8F-306DA9F4125E


I used:

/usr/bin/python -u /home/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a --agreement n

Below full build output:

What is wrong with my command?

  1. It seems like your command above is incorrect. It should be (please see “:” armeabi-v7a:x86):
    cocos gen-libs -p=android --app-abi armeabi-v7a:x86
  2. It seems like cocos gen-libs does not work for release

@zhangxm Could you check it?


I checked v3 latest version (with your pull request) and was able to build new project with “gradlew build”. Thank you:

But cpp-tests, cpp-empty-test failed with “gradlew build”:


Please see my CI output:

/usr/bin/python -u /Users/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos.py gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a --agreement n
running: ‘/Users/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos compile -s /Users/travis/build/mariusz102102/cocos2d-x/tests/cpp-empty-test -p android --ndk-mode release --app-abi armeabi-v7a --ap android-15’
/Users/travis/build/mariusz102102/cocos2d-x/tools/cocos2d-console/bin/cocos: line 4: shell_session_update: command not found
Building mode: debug
Using Android Studio project : /Users/travis/build/mariusz102102/cocos2d-x/tests/cpp-empty-test/proj.android
Building apk…
running: ‘"/Users/travis/build/mariusz102102/cocos2d-x/tests/cpp-empty-test/proj.android/gradlew" --parallel --info assembleDebug -PPROP_TARGET_SDK_VERSION=15 -PPROP_APP_ABI=armeabi-v7a -PPROP_NDK_MODE=release’

It seems like “assembleDebug” is incorrect inside “cocos gen-libs”

Could you send me correct commands for release gen-libs android build?
How can I use “gen-libs android build” with new project (“cocos new”)?



Yea, because before that, I’ve used:
cocos gen-libs -p android --ap android-19 --app-abi x86:armeabi-v7a

Can I specify api 19? as I my game will be targeted to minimum android v4.4

Because, after running command bellow, I’ve got automatically installed api 14:

Which I will never use and installed before.


@zhangxm Also, from help of gen libs:
cocos gen-libs -help

-m {debug,release}, --mode {debug,release}
Generate cocos libs for debug or release. Default is

But it’s debug by default, which is right(release should be only when I specify to built to it):


@zhangxm When I opened my project, configured for prebuilt libs I’ve got an error:

Screen Shot

From http://www.cocos2d-x.org/docs/cocos2d-x/en/editors_and_tools/prebuilt_libraries.html
I can’t find any useful information of how to.

@slackmoehrle So, how can I setup a new project for android with prebuilt libs? I’m looking for step-by-step guide for prebuilt’s for this engine with all details. For iOS and android.


@zhangxm After running:

cocos gen-libs -p=android --app-abi armeabi-v7a:x86

I got BUILD SUCCESSFUL but no prebuilt folder created. Where is it?


I fixed it with https://github.com/cocos2d/cocos2d-x/pull/18594 - I didn’t check it on my system, but it’s the same error as in new projects, which I fixed yesterday.

@zhangxm Maybe you can merge it later into v3. I wonder why this didn’t failed in your CI system. You should change the APK build from assemble to build, because this does more checks (and is the preferred command for release builds) - if this is called on the CI server. The deprecated cocos command called assemble instead of build.


@mars3142 Thank you! cpp-tests and cpp-empty-test compiled with “gradlew build”

@zhangxm @slackmoehrle did you have chance to check “cocos gen-libs” ?


@CrazyHappyGame what’s the issue? Could you please describe it in more detail? I will ask @drelaptop help to check it. Thanks.

  1. It fails for i.e.
    cocos gen-libs -p android -m release --ap android-15 --app-abi armeabi-v7a
  2. We do not know how to use Android gen-libs


@zhangxm in my previous post I described all problems 1,2,3,4. Very strange why you asking which problems…

However, it is obvious that prebuilt feature is ignored. @CrazyHappyGame I think only if someone else, who know android very good, like @mozartalouis, will do this and save the world of prebuilt’s :smiley: