【发布时间】:2017-09-20 03:41:24
【问题描述】:
一段时间以来,我一直在尝试使用 android studio 中的 BaseGameUtils 在我的 libgdx 游戏中实现 google play 游戏服务,这可以正常工作并正确初始化,但仅限于最新版本的 android,如 Oreo 或 Nougat。早期版本在应用打开后立即显示以下异常:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xx.mygame, PID: 1234
java.lang.VerifyError: com/google/android/gms/common/api/GoogleApiClient$Builder
at com.google.example.games.basegameutils.GameHelper.createApiClientBuilder(GameHelper.java:260)
at com.google.example.games.basegameutils.GameHelper.setup(GameHelper.java:297)
at com.xx.mygame.AndroidLauncher.onCreate(AndroidLauncher.java:31)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
我一直在调查 BaseGameUtils 模块的文件,试图找出问题所在,但我无能为力。任何帮助表示赞赏
这是 build.gradle 文件:
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-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile "com.android.support:support-core-utils:26.0.0"
compile 'com.google.android.gms:play-services-base:11.0.4'
compile "com.google.android.gms:play-services-games:11.0.4"
compile project(":BaseGameUtils")
}}
Build.gradle(模块:BaseGameUtils)
dependencies {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('appcompat_library_version')) {
ext.appcompat_library_version = '20.0.+'
}
if (!project.hasProperty('support_library_version')) {
ext.support_library_version = '20.0.+'
}
if (!project.hasProperty('gms_library_version')) {
ext.gms_library_version = '8.4.0'
}
compile "com.android.support:appcompat-v7:${appcompat_library_version}"
compile "com.android.support:support-v4:${support_library_version}"
compile "com.google.android.gms:play-services-games:${gms_library_version}"
compile "com.google.android.gms:play-services-plus:${gms_library_version}"
}
android {
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_compile_version')) {
ext.android_compile_version = 23
}
if (!project.hasProperty('android_version')) {
ext.build_tools_version = "23.0.2"
}
// Set defaults so that BaseGameUtils can be used outside of BasicSamples
if (!project.hasProperty('android_min_sdk_version')) {
// Google Play Services minimum requirements is 14
ext.android_min_sdk_version = 14
}
compileSdkVersion android_compile_version
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion android_min_sdk_version
targetSdkVersion android_compile_version
}
}
【问题讨论】:
-
显示
build.gradle对android 有依赖关系的文件,例如build.gradle文件BaseGameUtils和android 模块。 -
@AbhishekAryan 好的,我已经粘贴了 build.gradle!
标签: android android-studio libgdx google-play-services