I'm keep getting this error while build apk file with option minifyEnabled true
.
Application build process and installation been success but failed to launch with this error.
I have tired to find the the class library. I'm not much familiar with Android app development, please help me with this,
Error stack-trace
05-11 11:44:09.307 10196-10196/? E/cutils: to chown(/mnt/shell/emulated/0, 0, 0)
05-11 11:44:09.307 10196-10196/? E/cutils: to chown(/mnt/shell/emulated/obb, 0, 0)
05-11 11:44:09.308 10196-10196/? E/cutils: to chown(/storage/emulated/0/Android, 0, 0)
05-11 11:44:09.308 10196-10196/? E/cutils: to chown(/storage/emulated/0/Android/obb, 0, 0)
05-11 11:44:09.393 10196-10196/? E/dalvikvm: Could not find class 'android.app.job.JobScheduler', referenced from method com.google.android.gms.internal.zzcll.zzbax
05-11 11:44:09.394 10196-10196/? E/dalvikvm: Could not find class 'android.app.job.JobScheduler', referenced from method com.google.android.gms.internal.zzcll.zzs
05-11 11:44:09.405 10196-10211/? E/dalvikvm: Could not find class 'android.app.AppOpsManager', referenced from method com.google.android.gms.internal.zzbhe.zzf
05-11 11:44:09.647 10196-10216/? E/JniHelper: Failed to find static method id of setAnimationInterval
Failed to find static java method. Class name: org/cocos2dx/lib/Cocos2dxRenderer, method name: setAnimationInterval, signature: (F)V
05-11 11:44:09.840 10196-10216/? E/JniHelper: Failed to find static method id of setAnimationInterval
Failed to find static java method. Class name: org/cocos2dx/lib/Cocos2dxRenderer, method name: setAnimationInterval, signature: (F)V
05-11 11:44:09.872 10196-10216/? E/AndroidRuntime: FATAL EXCEPTION: GLThread 11342
java.lang.NoClassDefFoundError: org/cocos2dx/lib/Cocos2dxDownloader
at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:73)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.cocos2dx.lib.Cocos2dxDownloader" on path: DexPathList[[zip file "/data/app/com.company.game-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.company.game-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method)
at org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:73)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
gradle.properties
PROP_COMPILE_SDK_VERSION=14
PROP_MIN_SDK_VERSION=14
PROP_TARGET_SDK_VERSION=22
PROP_APP_PLATFORM=14
# Supported ABIs are [armeabi,arm64-v8a, armeabi-v7a, mips, x86].
PROP_APP_ABI=armeabi-v7a:x86
build.gradle
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.android.application'
android {
compileSdkVersion 14
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
defaultConfig {
applicationId "com.company.game"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
externalNativeBuild {
ndkBuild {
if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
// skip the NDK Build step if PROP_NDK_MODE is none
targets 'game'
arguments 'NDK_TOOLCHAIN_VERSION=4.9'
arguments 'APP_PLATFORM=android-' + PROP_APP_PLATFORM
def module_paths = [project.file("../../cocos2d").absolutePath,
project.file("../../cocos2d/cocos").absolutePath,
project.file("../../cocos2d/external").absolutePath]
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// should use '/'
module_paths = module_paths.collect { it.replaceAll('\\\\', '/') }
arguments 'NDK_MODULE_PATH=' + module_paths.join(";")
} else {
arguments 'NDK_MODULE_PATH=' + module_paths.join(':')
}
arguments '-j' + Runtime.runtime.availableProcessors()
abiFilters.addAll(PROP_APP_ABI.split(':').collect { it as String })
}
}
}
signingConfig signingConfigs.release
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "../../Resources"
}
externalNativeBuild {
ndkBuild {
if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
// skip the NDK Build step if PROP_NDK_MODE is none
path "jni/Android.mk"
}
}
}
buildTypes {
release {
minifyEnabled true // Here
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=0'
}
}
}
debug {
minifyEnabled true // and here
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
externalNativeBuild {
ndkBuild {
arguments 'NDK_DEBUG=1'
}
}
}
}
buildToolsVersion '27.0.3'
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':libcocos2dx')
implementation 'com.google.firebase:firebase-ads:11.8.0'
implementation 'com.google.android.gms:play-services-base:11.8.0'
}
apply plugin: 'com.google.gms.google-services'
proguard-rules.pro
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
#-keep class com.google.android.gms.** { *; }
#-dontwarn com.google.android.gms.**
# com.google.android.gms:play-services-base:11.8.0
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
# com.google.firebase:firebase-ads:11.8.0
-keep public class com.google.firebase.* { public *; }
-dontwarn com.google.firebase.**
-keep public class com.google.android.gms.ads.* { public *; }
-dontwarn com.google.android.gms.ads.**
-keep public class com.google.ads.** { public *; }
-dontwarn com.google.ads.**
This is a Cocos2d-x v3 c++ Game. Thanks
JobScheduler
API is was introduced from API 5.0. So it won't work on older versions like 4.2.2 as a result you encounter the error
For versions lower than 5.0, use Firebase JobDispatcher
. Refer this documentation for more details.
Firebase JobDispatcher is an open-source library that provides an API similar to JobScheduler in the Android platform. Firebase JobDispatcher serves as a JobScheduler-compatibility layer for apps targeting versions of Android lower than 5.0 (API level 21).
You should also update compileSdkVersion
to 26 or 27 from 14.