Prebuilt generation not working in 3.13.1 and 3.11.1

hello there,
i’m trying to generate prebuilts with cocos command but i stumble into errors. does anyone know a workaround?

----- trying prebuilt 3.13.1

max:cocos2d-x-3.13.1 cocos gen-libs -c -p android

Updated project.properties
Updated local.properties
Updated file /usr/local/cocos/cocos2d-x-3.13.1/cocos/platform/android/java/proguard-project.txt
Building native…
NDK build mode: release
running: ‘/usr/local/android/ndk-bundle/ndk-build -C /usr/local/cocos/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android -j4 APP_ABI=“armeabi” NDK_MODULE_PATH=/usr/local/cocos/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/:/usr/local/cocos/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos/:/usr/local/cocos/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/external:/usr/local/cocos/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos/scripting NDK_TOOLCHAIN_VERSION=4.9’

[armeabi] StaticLibrary : libluacocos2d.a
[armeabi] StaticLibrary : libsimulator.a
[armeabi] StaticLibrary : libjscocos2d.a
[armeabi] StaticLibrary : libcocos2d.a
[armeabi] StaticLibrary : liblocalstorage.a
[armeabi] StaticLibrary : libcocostudio.a
[armeabi] StaticLibrary : libcocosbuilder.a
[armeabi] StaticLibrary : libcocos3d.a
[armeabi] StaticLibrary : libspine.a
[armeabi] StaticLibrary : libui.a
[armeabi] StaticLibrary : libcocosdenshion.a
[armeabi] StaticLibrary : flatbuffers.a
[armeabi] StaticLibrary : libextension.a
[armeabi] StaticLibrary : libaudioengine.a
[armeabi] StaticLibrary : libbox2d.a
[armeabi] StaticLibrary : libnetwork.a
[armeabi] StaticLibrary : libcocos2dxinternal.a
[armeabi] StaticLibrary : librecast.a
[armeabi] StaticLibrary : libbullet.a
[armeabi] StaticLibrary : libluacocos2dandroid.a
[armeabi] StaticLibrary : libjscocos2dandroid.a
[armeabi] StaticLibrary : libcocos2dandroid.a
[armeabi] StaticLibrary : libcpufeatures.a
[armeabi] SharedLibrary : libcocos2dlua.so
/usr/local/cocos/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos//./base/CCConsole.cpp:423: error: undefined reference to ‘bzero’
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libcocos2dlua.so] Error 1
Error running command, return code: 2.
Error running command, return code: 14.
max:cocos2d-x-3.13.1

----- trying prebuilt 3.11.1

max:cocos2d-x-3.11.1 cocos gen-libs -c -p android

Building native…
NDK build mode: release
running: ‘/usr/local/android/ndk-bundle-r10e/ndk-build -C /usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android -j4 APP_ABI=“armeabi” NDK_MODULE_PATH=/usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/:/usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos/:/usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/external:/usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos/scripting NDK_TOOLCHAIN_VERSION=4.9’

Android NDK: WARNING: Unsupported source file extensions in /usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos//scripting/js-bindings/proj.android/Android.mk for module cocos2d_js_static
Android NDK:
make: Entering directory /usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android' [armeabi] Compile++ arm : cocos2dlua_shared <= main.cpp [armeabi] Compile++ arm : cocos2dlua_shared <= AppDelegate.cpp [armeabi] Compile++ arm : cocos2dlua_shared <= RuntimeJsImpl.cpp [armeabi] Compile++ arm : cocos2dlua_shared <= RuntimeLuaImpl.cpp make: *** No rule to make target/Applications/Cocos/Cocos2d-x/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos//scripting/lua-bindings/proj.android/…/manual/CCLuaBridge.cpp’, needed by obj/local/armeabi/objs/cocos2d_lua_static/__/manual/CCLuaBridge.o'. Stop. make: *** Waiting for unfinished jobs.... [armeabi] Compile arm : cocos2dlua_shared <= lua_debugger.c make: Leaving directory/usr/local/cocos/cocos2d-x-3.11.1/tools/simulator/frameworks/runtime-src/proj.android’
Error running command, return code: 2.
Error running command, return code: 14.
max:cocos2d-x-3.11.1

----- setup

os x el capitan
xcode 7
cocos2dx 3.11.1 / 3.13.1
cmake version 3.3.2
ndk r10e / r12b

I am seeing an issue with v3.13.1, but not v3.11.1. I’ll talk with the engineering team about this. I started a GitHub issue for the issues I am seeing.

ok, I my issue was solved by updating the dependencies. I can compile both iOS and Android fine now.

Thank you for your help. I downloaded cocos from github, updated deps, and run cocos gen libs for android and it works.
But on 3.13.1 downloaded from the site, python download-deps.py says everything is up to date. Here’s the diffs:


external/config.json version directly downloaded from site:

{
“version”:“v3-deps-109”,
“zip_file_size”:“135566431”,
“repo_name”:“cocos2d-x-3rd-party-libs-bin”,
“repo_parent”:“https://github.com/cocos2d/”,
“move_dirs”:{
“fbx-conv”:“tools”
}
}

changelog:

cocos2d-x-3.13.1 Sep 13 2016

[FIX] Label color broken
[FIX] application will crash in debug mode if don’t specify a design resolution
[FIX] application may crash if coming from background by clicking application icon on Android
[FIX] AudioEngine can not play audio if the audio lies outside APK on Android
[FIX] AudioEngine::stop() will trigger finish callback on Android
[FIX] application will crash if using SimpleAudioEngine or new AudioEngine to play audio on Android 2.3.x
[FIX] object.setString() has not effect if passing a number on JSB

external/config.json downloaded from github:

{
“version”:“v3-deps-111”,
“zip_file_size”:“135487488”,
“repo_name”:“cocos2d-x-3rd-party-libs-bin”,
“repo_parent”:“https://github.com/cocos2d/”,
“move_dirs”:{
“fbx-conv”:“tools”
}
}

changelog

cocos2d-x-3.13 Aug 22 2016

[HIGHLIGHT] add VR plugin
[HIGHLIGHT] support ETC1 alpha channel
[HIGHLIGHT] fix AudioEngine performance for Android 4.2+
[HIGHLIGHT] improve canvas renderer performance with dirty region
[HIGHLIGHT] add Andorid arm-64 support
[HIGHLIGHT] use luajit for Android arm-64
[HIGHLIGHT] switch to use gcc 4.9
[HIGHLIGHT] upgrade CURL to 7.50.0
[HIGHLIGHT] upgrade Spine to 3.4
[HIGHLIGHT] upgrade glfw to 3.2


looks like v3.13 has higher external libraries version of 3.13.1. is that correct? Or shall i upgrade v.3.13 libs to v. 3.13.1 simply?
Thank you again

another one error with gen-libs

[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= JniHelper.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= TouchesJni.cpp
[armeabi] Compile thumb  : cpufeatures <= cpu-features.c
[armeabi] StaticLibrary  : libluacocos2d.a
[armeabi] StaticLibrary  : libsimulator.a
[armeabi] StaticLibrary  : libjscocos2d.a
[armeabi] StaticLibrary  : liblocalstorage.a
[armeabi] StaticLibrary  : libcocostudio.a
[armeabi] StaticLibrary  : libcocosbuilder.a
[armeabi] StaticLibrary  : libcocos3d.a
[armeabi] StaticLibrary  : libspine.a
[armeabi] StaticLibrary  : libui.a
[armeabi] StaticLibrary  : libcocosdenshion.a
[armeabi] StaticLibrary  : flatbuffers.a
[armeabi] StaticLibrary  : libextension.a
[armeabi] StaticLibrary  : libaudioengine.a
[armeabi] StaticLibrary  : libbox2d.a
[armeabi] StaticLibrary  : libnetwork.a
[armeabi] StaticLibrary  : libcocos2dxinternal.a
[armeabi] StaticLibrary  : librecast.a
[armeabi] StaticLibrary  : libbullet.a
[armeabi] StaticLibrary  : libluacocos2dandroid.a
[armeabi] StaticLibrary  : libjscocos2dandroid.a
[armeabi] StaticLibrary  : libcocos2dandroid.a
[armeabi] StaticLibrary  : libcpufeatures.a
[armeabi] SharedLibrary  : libcocos2dlua.so
[armeabi] Install        : libcocos2dlua.so => libs/armeabi/libcocos2dlua.so
Building apk...
generate byte code ............
only build 32bit
Traceback (most recent call last):
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/bin/cocos.py", line 998, in <module>
    run_plugin(command, argv, plugins)
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/bin/cocos.py", line 916, in run_plugin
    plugin.run(argv, dependencies_objects)
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/plugins/plugin_compile/project_compile.py", line 1551, in run
    self.build_android()
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/plugins/plugin_compile/project_compile.py", line 527, in build_android
    self.apk_path = builder.do_build_apk(build_mode, self._no_apk, output_dir, self._custom_step_args, self)
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/plugins/plugin_compile/build_android.py", line 493, in do_build_apk
    build_type = self._get_build_type(compile_obj.app_abi)
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/plugins/plugin_compile/build_android.py", line 444, in _get_build_type
    return self._do_get_build_type(param_of_appabi)
  File "/Volumes/hdd/dev/cocos2d-x-repo/tools/cocos2d-console/plugins/plugin_compile/build_android.py", line 435, in _do_get_build_type
    return LuaBuildType.ONLY_BUILD_32BIT
NameError: global name 'LuaBuildType' is not defined
Error running command, return code: 1.

cocos2dx 3.13.1
OSX 10.10.5
NDK 12b
SDK r24

what command did you use?

@slackmoehrle
cocos gen-libs -p android -m release

does it work if you specify a specific api level? Something like:

--ap android-19

@slackmoehrle
no it is does not work

Updated project.properties
Updated local.properties
Updated file /Volumes/hdd/dev/cocos2d-x-repo/tools/simulator/frameworks/runtime-src/proj.android/proguard-project.txt
running: '/Volumes/hdd/opt/android-sdk-r24/tools/android update lib-project -p /Volumes/hdd/dev/cocos2d-x-repo/cocos/platform/android/java -t android-16'

Updated project.properties
Updated local.properties
Updated file /Volumes/hdd/dev/cocos2d-x-repo/cocos/platform/android/java/proguard-project.txt
Building native...
NDK build mode: release
running: '/Volumes/hdd/opt/android-ndk-r12b/ndk-build -C /Volumes/hdd/dev/cocos2d-x-repo/tools/simulator/frameworks/runtime-src/proj.android -j4 APP_ABI="android-19" NDK_MODULE_PATH=/Volumes/hdd/dev/cocos2d-x-repo/tools/simulator/frameworks/runtime-src/proj.android/../../../../../:/Volumes/hdd/dev/cocos2d-x-repo/tools/simulator/frameworks/runtime-src/proj.android/../../../../../cocos/:/Volumes/hdd/dev/cocos2d-x-repo/tools/simulator/frameworks/runtime-src/proj.android/../../../../../external:/Volumes/hdd/dev/cocos2d-x-repo/tools/simulator/frameworks/runtime-src/proj.android/../../../../../cocos/scripting NDK_TOOLCHAIN_VERSION=4.9'

Android NDK: WARNING: APP_PLATFORM android-16 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml    
Android NDK: NDK Application 'local' targets unknown ABI(s): android-19    
Android NDK: Please fix the APP_ABI definition in ./jni/Application.mk    
/Volumes/hdd/opt/android-ndk-r12b/build/core/setup-app.mk:120: *** Android NDK: Aborting    .  Stop.
Error running command, return code: 2.
Error running command, return code: 14.

I was able to run the command and generate libs, at last. Looks like it was something about my setup. Ndk not in the expected directory ‘ndk-bundle’ under android installation gave out an error, i changed it back.

It worked in 3.13.1, and gave out the usual
-rw-r–r-- 1 max staff 118900264 Sep 15 13:41 libcocos2d iOS.a
-rw-r–r-- 1 max staff 58383456 Sep 15 13:41 libjscocos2d iOS.a
-rw-r–r-- 1 max staff 27467712 Sep 15 13:41 libluacocos2d iOS.a
-rw-r–r-- 1 max staff 3900264 Sep 15 13:41 libsimulator iOS.a

under ios and mac, and an exploded format library for android, that is

-rw-r–r-- 1 max staff 71451496 Sep 15 13:42 libcocos2dxinternal.a
-rw-r–r-- 1 max staff 2177714 Sep 15 13:42 libcocos2dandroid.a
-rw-r–r-- 1 max staff 8 Sep 15 13:42 libcocos2d.a
-rw-r–r-- 1 max staff 19640504 Sep 15 13:42 libbullet.a
-rw-r–r-- 1 max staff 3114980 Sep 15 13:42 libbox2d.a
-rw-r–r-- 1 max staff 4835998 Sep 15 13:42 libaudioengine.a
-rw-r–r-- 1 max staff 9278426 Sep 15 13:42 flatbuffers.a
-rw-r–r-- 1 max staff 14816604 Sep 15 13:42 libui.a
-rw-r–r-- 1 max staff 1969948 Sep 15 13:42 libspine.a
-rw-r–r-- 1 max staff 9082592 Sep 15 13:42 libsimulator.a
-rw-r–r-- 1 max staff 1576208 Sep 15 13:42 librecast.a
-rw-r–r-- 1 max staff 4523018 Sep 15 13:42 libnetwork.a
-rw-r–r-- 1 max staff 336006 Sep 15 13:42 libluacocos2dandroid.a
-rw-r–r-- 1 max staff 49427190 Sep 15 13:42 libluacocos2d.a
-rw-r–r-- 1 max staff 252382 Sep 15 13:42 liblocalstorage.a
-rw-r–r-- 1 max staff 387522 Sep 15 13:42 libjscocos2dandroid.a
-rw-r–r-- 1 max staff 76017402 Sep 15 13:42 libjscocos2d.a
-rw-r–r-- 1 max staff 38007318 Sep 15 13:42 libextension.a
-rw-r–r-- 1 max staff 40478 Sep 15 13:42 libcpufeatures.a
-rw-r–r-- 1 max staff 42797776 Sep 15 13:42 libcocostudio.a
-rw-r–r-- 1 max staff 355756 Sep 15 13:42 libcocosdenshion.a
-rw-r–r-- 1 max staff 9469480 Sep 15 13:42 libcocosbuilder.a
-rw-r–r-- 1 max staff 13583794 Sep 15 13:42 libcocos3d.a

is that normal? isn’t that way in older versions, is it?

I got this error many times
command:
cocos gen-libs -p android --ap android-19 --app-abi armeabi
cocos2dx 3.13.1
ndk r13b

Your command doesn’t help :frowning:

/Users/piotr/Documents/pierdoly/cocos2d-x-3.13.1/tools/simulator/frameworks/runtime-src/proj.android/…/…/…/…/…/cocos//./base/CCConsole.cpp:423: error: undefined reference to ‘bzero’
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libcocos2dlua.so] Error 1
Error running command, return code: 2.
Error running command, return code: 14.

I solved it by delete all object in folder tool/simlator/frameworks/runtime-src/proj.android/obj

3 Likes

Worked! Thanks! :slight_smile:

Same here.
I’m trying:

cocos gen-libs -p android --ap android-19 --app-abi armeabi
and
cocos gen-libs -c -p android --ap android-19

Always getting same error:

Why also it’s showing that it will build in debug?

I’m using just downloaded cocos2d-x-3.13.1 By the way - I was able to build libs for iOS and macOS.

And to be sure. Do you have Android-10 installed?

android list targets

id: 1 or "android-19"
     Name: Android 4.4.2
     Type: Platform
     API level: 19
     Revision: 4
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 2 or "android-22"
     Name: Android 5.1.1
     Type: Platform
     API level: 22
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 3 or "android-25"
     Name: Android 7.1.1
     Type: Platform
     API level: 25
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.

So, @slackmoehrle I do not give up. However, really I’m struggling already 3rd day, just trying to set up this and build for android.
I don’t see any explanation of my problems, but only this - it’s feels like you never tested latest cocos2d-x on macOS, right? Didn’t check for setup & build etc.? Because main target is windows?

Also, why when I creating project with static libs I get no proj.android-studio inside my project. But if I create new project using source code I get this folder and I can probably try open it in Cocos Studio? Right? And how I can use Eclipse? Old tutorials and docs are not working … omg Please help!!! Better in my initial thread - Need help getting started with Cocos2d-x to build for iOS & android

Install Android-10 I recall something about the libs use an older version to maintain comparability.

Or I think you can change the version in project.properties.

@zhangxm can you help here? We should notate how to fix in our docs.

I asked @zhangbin to take a look.