I am having trouble setting up cocos2d-x-3.11.1 for android on Windows 10. I’m following this tutorial. When I run python android-build.py -p 23 cpp-tests
I get the following error:
I have:
cocos2d-x-3.11.1
apache-ant-1.9.1
jdk1.8.0_91
android-ndk-r11c / android-ndk-r10c / android-ndk-r19d (I’ve tried all of them)
Android Studio v2.1
python 2.7.9
(Sorry if this is bad, it’s my first time posting on forums.)
I’ve changed all the files you stated however:
If I run cocos run -p android --ap android-22 in the cpp-tests folder like you said, it gives me the following error.
Building mode: debug
Using Eclipse project : Y:\cocos2d-x-3.11.1\tests\cpp-tests\proj.android
The Android-platform of project 'Y:\cocos2d-x-3.11.1\tests\cpp-tests\proj.androi
d' should be equal/larger than 23, but 22 is specified.
If I run python android-build.py -p 22 cpp-tests, it seems to still be building with API 23 and gives following error.
[gettype] [Fatal Error] :8:73: The prefix "andorid" for attribute "andorid:tar
getSdkVersion" associated with an element type "uses-sdk" is not bound.
Simple way: download cocos2d-x one more time and use my solution on clean version.
Long way: there are 2 or more config files, that are changed during building, so you have to manually change the values inside them. I don’t remember the name of these files and I don’t have my computer here, so I will help you later.
And you have a typo: andorid
EDIT: the mentioned file name is project.properties.
Open it and change target=android-23 into target=android-22.
When you run build with higher android version, the file is changed. But when you are trying to build with lower version, you have to change it manually. Probably good practice would be clearing all files generated during previous building (with higher android), but I don’t do it and it works.
Important: project.properties can be found in all sub-project (for example if you are using sdkbox), and all copies are modified during building.
One more option: add org.apache.http.legacy.jar from android sdk (platforms/android-23/optional) to cocos2d/cocos/platforms/android/java/libs to be able to compile with android-23, but I can’t compile it with proguard enabled, so I don’t use this solution.
I used the long way and it worked like a charm although I had to change a few extra files (The ones you mentioned but in the cocos/platform/android/java).
Thanks
I found a new hope in this thread after several days have the same problem.
I has add Android 5.1.1 (API 22) and edit some files mentioned above (AndroidManifest.xml,Application.mk, and also AndroidManifest.xml in cocos/platform/android/java), but I still getting error when trying to run python android-build.py -p 22 cpp-tests. This is error message:
At global scope:
cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat"
[armeabi] Compile++ thumb: cocos2dxandroid_static <= Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp
[armeabi] Compile++ thumb: cocos2dxandroid_static <= JniHelper.cpp
make.exe: *** No rule to make target `C:/Users/toni/AppData/Local/Android/android-ndk-r11c/build//../sources/android/cpufeatures/cpu-features.c', needed by `obj[armeabi]/ Compile++ thumb:l cocos2dxandroid_static <= TouchesJni.cppo
cal/armeabi/objs-debug/cpufeatures/cpu-features.o'. Stop.
make.exe: *** Waiting for unfinished jobs....
make.exe: Leaving directory `D:/cocos2d-x-3.11.1/tests/cpp-tests/proj.android'
Error running command, return code: 2.
Build dynamic library for project [ D:\cocos2d-x-3.11.1\build\..\tests/cpp-tests ] fails!
Can somebody help me? I am new in cocos2dx and this makes me little frustated haha…
Hey guys, i have trouble while debugging in my phone, it so freak, if i compiling or debugging in my friend PC it always done, but why it always error in my PC? Do you gave solution for my problem?
Based on: cocos2d-x-3.10
Updated project.properties
Updated local.properties
Updated file C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\proguard-project.txt
It seems that there are sub-projects. If you want to update them
please use the --subprojects parameter.
Android NDK: WARNING: APP_PLATFORM android-17 is larger than android:minSdkVersion 9 in ./AndroidManifest.xml
make.exe: Entering directory C:/Users/Aqomal/Documents/Cocos/CocosProjects/bundersilang/proj.android' [armeabi] StaticLibrary : libcpufeatures.a [armeabi] SharedLibrary : libcocos2dcpp.so [armeabi] Install : libcocos2dcpp.so => libs/armeabi/libcocos2dcpp.so make.exe: Leaving directoryC:/Users/Aqomal/Documents/Cocos/CocosProjects/bundersilang/proj.android’
Buildfile: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\build.xml
-check-env:
[checkenv] Android SDK Tools Revision 25.1.7
[checkenv] Installed at C:\Programming\android-sdk
-setup:
[echo] Project Name: bundersilang
[gettype] Project Type: Application
-pre-clean:
clean:
[delete] Deleting directory C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin
[delete] Deleting directory C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\gen
[getlibpath] Library dependencies:
[getlibpath] No Libraries
[subant] No sub-builds to iterate on
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 25.1.7
[checkenv] Installed at C:\Programming\android-sdk
-setup:
[echo] Project Name: bundersilang
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-pre-build:
-build-setup:
[getbuildtools] Using latest Build Tools: 24.0.0
[echo] Resolving Build Target for bundersilang…
[gettarget] Project Target: Android 4.2.2
[gettarget] API level: 17
[echo] ----------
[echo] Creating output directories if needed…
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\res
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\rsObj
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\rsLibs
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\gen
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\classes
[mkdir] Created dir: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\dexedLibs
[echo] ----------
[echo] Resolving Dependencies for bundersilang…
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[echo] ----------
[echo] Building Libraries with ‘debug’…
[subant] No sub-builds to iterate on
-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
[echo] Handling aidl files…
[aidl] Found 1 AIDL files.
[aidl] Compiling 1 AIDL files.
[echo] ----------
[echo] Handling RenderScript files…
[echo] ----------
[echo] Handling Resources…
[aapt] Generating resource IDs…
[echo] ----------
[echo] Handling BuildConfig class…
[buildconfig] Generating BuildConfig class.
-pre-compile:
-compile:
[javac] Compiling 31 source files to C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\src\org\cocos2dx\lib\Cocos2dxDownloader.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
-post-compile:
-obfuscate:
-dex:
[dex] input: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\bin\classes
[dex] input: C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\libs\android-async-http-1.4.8.jar
[dex] Pre-Dexing C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\libs\android-async-http-1.4.8.jar -> android-async-http-1.4.8-3c8fc99400c13421df7aa928e8691fb9.jar
[dx] java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0
[dx] at java.lang.ClassLoader.defineClass1(Native Method)
[dx] at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
[dx] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[dx] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
[dx] at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
[dx] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[dx] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[dx] at java.security.AccessController.doPrivileged(Native Method)
[dx] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[dx] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
[dx] at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
[dx] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[dx] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[dx] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
[dx] Exception in thread “main”
BUILD FAILED
C:\Programming\android-sdk\tools\ant\build.xml:888: The following error occurred while executing this line:
C:\Programming\android-sdk\tools\ant\build.xml:890: The following error occurred while executing this line:
C:\Programming\android-sdk\tools\ant\build.xml:902: The following error occurred while executing this line:
C:\Programming\android-sdk\tools\ant\build.xml:283: null returned: 1
Total time: 23 seconds
Building mode: debug
Using Eclipse project : C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android
Android platform not specified, searching a default one…
running: ‘“C:\Programming\android-sdk\tools\android” update project -t android-17 -p C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android’
Building native…
NDK build mode: release
NDK_TOOLCHAIN_VERSION: 4.9
running: ‘“C:\Programming\android-ndk-r10e\ndk-build” -C C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android -j3 NDK_MODULE_PATH=C:\Cocos\cocos2d-x/cocos2d-x-3.10;C:\Cocos\cocos2d-x/cocos2d-x-3.10/cocos;C:\Cocos\cocos2d-x/cocos2d-x-3.10/external NDK_TOOLCHAIN_VERSION=4.9’
Building apk…
running: ‘“C:\Cocos\tools\ant\bin\ant” clean debug -f C:\Users\Aqomal\Documents\Cocos\CocosProjects\bundersilang\proj.android\build.xml -Dsdk.dir=“C:\Programming\android-sdk”’
Error running command, return code: 1.