我将Firebase SDK添加到我的Unity游戏中。 Unity编译得很好但是当我在Android设备上启动游戏时,它会在显示启动画面之前立即崩溃。
Logcat给出了以下错误。我还添加了我正在使用的gradle文件。有人有什么建议吗?
谢谢!
这是错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.puzzletime.jigsaw, PID: 10617
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbp;
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6335)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5927)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5866)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbp" on path: DexPathList[[zip file "/data/app/com.puzzletime.jigsaw-1/base.apk"],nativeLibraryDirectories=[/data/app/com.puzzletime.jigsaw-1/lib/arm, /data/app/com.puzzletime.jigsaw-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6335)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5927)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5866)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
这是我的gradle文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'AdinCube-Unity-606ebe', ext:'aar')
compile(name: 'GoogleAIDL', ext:'aar')
compile(name: 'GooglePlay', ext:'aar')
compile(name: 'NativeGallery', ext:'aar')
compile(name: 'ShortcutBadger-1.1.5', ext:'aar')
compile(name: 'adcolony-3.2.1', ext:'aar')
compile(name: 'admob-10.0.1', ext:'aar')
compile(name: 'amazon-dex-5.8.1.1', ext:'aar')
compile(name: 'applovin-7.1.0', ext:'aar')
compile(name: 'appnext-core-dex-1.7.7', ext:'aar')
compile(name: 'appnext-dex-1.7.7', ext:'aar')
compile(name: 'appnext-sdk-dex-1.7.7', ext:'aar')
compile(name: 'chartboost-dex-7.0.0', ext:'aar')
compile(name: 'common', ext:'aar')
compile(name: 'doubleclick-10.0.1', ext:'aar')
compile(name: 'exoplayer-r2.0.3', ext:'aar')
compile(name: 'facebook-4.26.0', ext:'aar')
compile(name: 'firebase-analytics-11.4.2', ext:'aar')
compile(name: 'firebase-analytics-impl-11.4.2', ext:'aar')
compile(name: 'firebase-analytics-impl-license-11.4.2', ext:'aar')
compile(name: 'firebase-analytics-license-11.4.2', ext:'aar')
compile(name: 'firebase-analytics-unity-4.2.1', ext:'aar')
compile(name: 'firebase-app-unity-4.2.1', ext:'aar')
compile(name: 'firebase-common-11.4.2', ext:'aar')
compile(name: 'firebase-common-license-11.4.2', ext:'aar')
compile(name: 'firebase-core-11.4.2', ext:'aar')
compile(name: 'firebase-iid-11.4.2', ext:'aar')
compile(name: 'firebase-iid-license-11.4.2', ext:'aar')
compile(name: 'mobile-native-popups', ext:'aar')
compile(name: 'mopub-4.14.0', ext:'aar')
compile(name: 'mopub-banner-4.14.0', ext:'aar')
compile(name: 'mopub-base-4.14.0', ext:'aar')
compile(name: 'mopub-interstitial-4.14.0', ext:'aar')
compile(name: 'mopub-rewardedvideo-4.14.0', ext:'aar')
compile(name: 'play-services-ads-11.4.2', ext:'aar')
compile(name: 'play-services-ads-license-11.4.2', ext:'aar')
compile(name: 'play-services-auth-11.4.2', ext:'aar')
compile(name: 'play-services-auth-base-11.4.2', ext:'aar')
compile(name: 'play-services-base-11.4.2', ext:'aar')
compile(name: 'play-services-base-license-11.4.2', ext:'aar')
compile(name: 'play-services-drive-11.4.2', ext:'aar')
compile(name: 'play-services-games-11.4.2', ext:'aar')
compile(name: 'play-services-gass-11.4.2', ext:'aar')
compile(name: 'play-services-gass-license-11.4.2', ext:'aar')
compile(name: 'play-services-gcm-11.4.2', ext:'aar')
compile(name: 'play-services-gcm-license-11.4.2', ext:'aar')
compile(name: 'play-services-iid-11.4.2', ext:'aar')
compile(name: 'play-services-iid-license-11.4.2', ext:'aar')
compile(name: 'play-services-nearby-11.4.2', ext:'aar')
compile(name: 'play-services-tagmanager-v4-impl-10.0.1', ext:'aar')
compile(name: 'play-services-tasks-11.4.2', ext:'aar')
compile(name: 'play-services-tasks-license-11.4.2', ext:'aar')
compile(name: 'recyclerview-v7-25.0.1', ext:'aar')
compile(name: 'support-compat-25.2.0', ext:'aar')
compile(name: 'support-core-ui-25.2.0', ext:'aar')
compile(name: 'support-core-utils-25.2.0', ext:'aar')
compile(name: 'support-fragment-25.2.0', ext:'aar')
compile(name: 'support-media-compat-25.2.0', ext:'aar')
compile(name: 'support-v4-25.2.0', ext:'aar')
compile(name: 'unity-2.1.0', ext:'aar')
compile(name: 'utnotifications', ext:'aar')
compile(name: 'vungle-5.1.0', ext:'aar')
compile project(':Firebase')
compile project(':GoogleMobileAdsPlugin')
compile project(':MainLibProj')
compile project(':UTNotificationsRes')
compile project(':localizedappnamelib')
}
android {
compileSdkVersion 25
buildToolsVersion '23.0.2'
defaultConfig {
targetSdkVersion 25
applicationId 'com.xxx.xxx'
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "2g"
}
lintOptions {
abortOnError false
}
buildTypes {
debug {
jniDebuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
signingConfig signingConfigs.release
}
}
}
答案 0 :(得分:0)
看起来像谷歌播放服务版本之间的冲突,
您是否尝试过更新support- * .aar文件?
也许它与multi-dex有关?
我最近在Android 4.x上遇到过multi-dex的问题。某些lib存在但在运行时未找到。 请参阅此链接https://developer.android.com/studio/build/multidex.html#mdex-gradle