我有一个应用程序与Libgdx,我使用谷歌播放服务和appodeal的广告,突然它在某些设备上崩溃。在我的手机(Galaxy J5,API 22)上工作得很好,但是在另一部手机上它没有启动。有问题的手机是三星SM-G3815(Android 4.4.2,API 19)
07-29 19:05:48.758 10710-10710/com.NeverMind.MainClass.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.NeverMind.MainClass.android, PID: 10710
java.lang.NoClassDefFoundError: com.google.android.gms.games.Games$GamesOptions
at com.google.example.games.basegameutils.GameHelper.<init>(GameHelper.java:114)
at com.NeverMind.DontFall.android.AndroidLauncher.onCreate(AndroidLauncher.java:27)
at android.app.Activity.performCreate(Activity.java:5541)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
这就是它在AndroidLauncher中崩溃的地方:
gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
这就是它在GameHelper崩溃的地方:
GamesOptions mGamesApiOptions = GamesOptions.builder().build();
编辑1: 构建gradle文件:
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = 'DontFall'
gdxVersion = '1.6.4'
roboVMVersion = '1.5.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.6.0'
aiVersion = '1.5.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile 'com.google.android.gms:play-services-ads:8.1.0'
compile "com.google.android.gms:play-services-ads:8.1.0"
compile project(':BaseGameUtils')
}
android {
dexOptions {
incremental true
javaMaxHeapSize "2048M"
}
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}