3.15 problems with Android

Hey,

Somehow I have problems with the android project, my hello world app always stops/crash after running it on a device.
Do i have the right ndk version? ndk 14.1.3816874 (android studio)
Should i use the old Android or the Android-Studio(gradle) version

is there actually any way to compile the android project through command line? it always says android command is deprecated.

somehow with the new cocos version nothing is working.

Please help me.

are u sure that u using new cocos for compile? I think in cocos 3.15 it was fixed that u was unalbe to compile from console.

Also what android version u have on device, which min/target sdk versions u targeting? you need to provide more info.

I just downloaded the latest cocos(3.15) version and created a new project with the tutorial.
Iā€™ve tried it on mutliple devices, e.g Samsung S5 Android(6.0) API 23 through Android Studio

Can u paste your crash log, what it saying in console - maybe it will gives more info.

Regarding android not suported command u need to downgrade android sdk version there was already topic in forum about this.

05-24 09:50:02.035 843 4516 V WindowManager: addAppToken: AppWindowToken{4dbec8a token=Token{518a6f5 ActivityRecord{d816c2c u0 com.SleiTec.heroproject/org.cocos2dx.cpp.AppActivity t1905}}} to stack=1 task=1905 at 0
05-24 09:50:02.065 843 1649 I ActivityManager: Start proc 16584:com.SleiTec.heroproject/u0a281 for activity com.SleiTec.heroproject/org.cocos2dx.cpp.AppActivity
05-24 09:50:03.005 16584 16584 E AndroidRuntime: at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
05-24 09:50:03.005 16584 16584 E AndroidRuntime: at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
05-24 09:50:03.015 843 4516 W ActivityManager: Force finishing activity com.SleiTec.heroproject/org.cocos2dx.cpp.AppActivity
05-24 09:50:03.625 843 936 W ActivityManager: Activity pause timeout for ActivityRecord{d816c2c u0 com.SleiTec.heroproject/org.cocos2dx.cpp.AppActivity t1905 f}

logcat with grep cocos

it is hello world project, right? Without any custome code and sdkbox

yes.
I use the 26.0.3 so i should downgrade to 25.2.3 ?

yes, it will work with console then. Regarding error log is not clear ussualy there is bigger log with crash info in red, scroll manually until u see it.

so what i did when i created a project is the following:

first i create the project with the cocos tutorial using terminal cocos new ā€¦
Then open the android-studio project with android studio and try to run it.

then it says
+
Error:The SDK Build Tools revision (22.0.1) is too low for project ā€˜:MyGame2ā€™. Minimum required is 25.0.0
Update Build Tools version and sync project
Open File

when i set this to 25

following error occus

:libcocos2dx:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ā€˜:libcocos2dx:compileReleaseJavaWithJavacā€™.

Compilation failed; see the compiler error output for details.

As far as i know i have to get the org.apache.http.legacy.jar and put in the sdkā€™s api optional folder

never had so many problems with older cocos versions, whats going on, why does the fresh created cocos project cause so many problems?

Regarding that java issue - it could be that it doesnt know where to search NDK - u need to set NDK path in project settings. Also check that in build.gradle on top u have
import org.apache.tools.ant.taskdefs.condition.Os

gradle local.properties has the ndk path already

i had to put org.apache.http.legacy.jar in to cocos java libs folder for android to solve the java error.
iā€™Ve created a second new hello world project, with the same changes, same problem, the app just starts and straight stops

here some outout:

05-24 11:07:04.582 30899-30899/? E/Zygote: v2
05-24 11:07:04.582 30899-30899/? I/libpersona: KNOX_SDCARD checking this for 10282
05-24 11:07:04.582 30899-30899/? I/libpersona: KNOX_SDCARD not a persona
05-24 11:07:04.582 30899-30899/? I/SELinux: Function: selinux_compare_spd_ram, index[1], SPD-policy is existed. and_ver=SEPF_SECMOBILE_6.0.1 ver=11
05-24 11:07:04.582 30899-30899/? W/SELinux: Function: selinux_compare_spd_ram, index[1], priority [2], priority version is VE=SEPF_SECMOBILE_6.0.1_0030
05-24 11:07:04.592 30899-30899/? E/Zygote: accessInfo : 0
05-24 11:07:04.592 30899-30899/? W/SELinux: SELinux: seapp_context_lookup: seinfo=default, level=s0:c512,c768, pkgname=com.MyCompany.MyGame
05-24 11:07:04.592 30899-30899/? I/art: Late-enabling -Xcheck:jni
05-24 11:07:04.622 30899-30899/? D/TimaKeyStoreProvider: TimaSignature is unavailable
05-24 11:07:04.622 30899-30899/? D/ActivityThread: Added TimaKeyStore provider
05-24 11:07:04.752 30899-30899/com.MyCompany.MyGame W/ResourcesManager: getTopLevelResources: /data/app/com.MyCompany.MyGame-1/base.apk / 1.0 running in com.MyCompany.MyGame rsrc of package null
05-24 11:07:04.862 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_dependencies_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_dependencies_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:04.942 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_0_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_0_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:04.992 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_1_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_1_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.062 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_2_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_2_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.112 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_3_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_3_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.162 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.222 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.282 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.332 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.392 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.442 30899-30899/com.MyCompany.MyGame W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set=arm --instruction-set-features=smp,div,atomic_ldrd_strd --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=krait --instruction-set-features=default --dex-file=/data/app/com.MyCompany.MyGame-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm/data@app@com.MyCompany.MyGame-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
05-24 11:07:05.442 30899-30899/com.MyCompany.MyGame W/System: ClassLoader referenced unknown path: /data/app/com.MyCompany.MyGame-1/lib/arm
05-24 11:07:05.452 30899-30899/com.MyCompany.MyGame I/InstantRun: starting instant run server: is main process
05-24 11:07:05.492 30899-30899/com.MyCompany.MyGame W/ResourcesManager: getTopLevelResources: /data/app/com.MyCompany.MyGame-1/base.apk / 1.0 running in com.MyCompany.MyGame rsrc of package null
05-24 11:07:05.492 30899-30899/com.MyCompany.MyGame W/ResourcesManager: getTopLevelResources: /data/app/com.MyCompany.MyGame-1/base.apk / 1.0 running in com.MyCompany.MyGame rsrc of package null
05-24 11:07:05.512 30899-30899/com.MyCompany.MyGame D/AndroidRuntime: Shutting down VM
05-24 11:07:05.522 30899-30899/com.MyCompany.MyGame E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.MyCompany.MyGame, PID: 30899
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file ā€œ/data/app/com.MyCompany.MyGame-1/base.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_dependencies_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_0_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_1_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_2_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_3_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_4_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_5_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_6_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_7_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_8_apk.apkā€, zip file ā€œ/data/app/com.MyCompany.MyGame-1/split_lib_slice_9_apk.apkā€],nativeLibraryDirectories=[/data/app/com.MyCompany.MyGame-1/lib/arm, /vendor/lib, /system/lib]]] couldnā€™t find ā€œlibMyGame.soā€
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

there is your issue, check that android manifest MyGame matching in Android.mk configured lib name for cocos. Or maybe it just not generated

seems like 3.15.1 fixed all my problems, do you know if the new sdk also works with it, i donā€™t wanna try it, because maybe it will cause problems again xD

but got another problem with the commandline android compilation now, it sais unsuported min version 52 for java
java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0

This could result in a wrong JDK version. What does java -version say? I use 1.8.x without any problems.

it says
1.7.0_71 maybe i should update it then

1 Like