我正在开发一个应用程序。当我添加Firebase依赖项时,该应用程序开始崩溃,并且以下错误指示该问题。我无法理解问题。
2019-03-30 22:16:50.473 4289-4289/com.dhruvbhati.blackwallpaper E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dhruvbhati.blackwallpaper, PID: 4289
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/zza;
at com.google.android.gms.ads.InterstitialAd.<init>(Unknown Source)
at com.dhruvbhati.blackwallpaper.config.admob.initialInterstitial(admob.java:43)
at com.dhruvbhati.blackwallpaper.MainActivity.onCreate(MainActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.zza" on path: DexPathList[[zip file "/data/app/com.dhruvbhati.blackwallpaper-1/base.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.dhruvbhati.blackwallpaper-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.dhruvbhati.blackwallpaper-1/lib/x86_64, /system/lib64, /vendor/lib64]]
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.android.gms.ads.InterstitialAd.<init>(Unknown Source)
at com.dhruvbhati.blackwallpaper.config.admob.initialInterstitial(admob.java:43)
at com.dhruvbhati.blackwallpaper.MainActivity.onCreate(MainActivity.java:53)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
我希望该应用停止崩溃。
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:recyclerview-v7:26.+'
implementation 'com.android.support:design:26.+'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.github.bumptech.glide:glide:4.1.1'
implementation 'com.android.support:support-v4:26.+'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.github.javiersantos:AppUpdater:2.6.4'
implementation 'com.google.android.gms:play-services-ads:10.2.1'
implementation 'com.google.firebase:firebase-core:16.0.0:15.0.0'
}
apply plugin: 'com.google.gms.google-services'
也是我的项目级别
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
答案 0 :(得分:1)
此行
implementation 'com.google.firebase:firebase-core:16.0.0:15.0.0'
不正确,您应该使用16.0.0
版本或15.0.0
一般gradle导入是以下模式:
<group-id>:<artifact-id>:<version>
所以这个:
implementation 'com.google.firebase:firebase-core:16.0.0'
或这个:
implementation 'com.google.firebase:firebase-core:15.0.0'