Android Firebase NoClassDefFoundError: com.google.firebase.FirebaseOptions after updating to the new firebase

Android Firebase NoClassDefFoundError: com.google.firebase.FirebaseOptions after updating to the new firebase

我已经使用 Android Kitkat 将我的应用程序更新到新的 Firebase =]

这是我的 logcat 当 运行 在 Android Kitkat 上:

AndroidRuntime: FATAL EXCEPTION: main
    Process: com.lemon.kenhnhacvn, PID: 23133
    java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
      at com.google.firebase.FirebaseApp.zzek(Unknown Source)
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
      at android.app.ActivityThread.installProvider(ActivityThread.java:4818)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4413)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4353)
      at android.app.ActivityThread.access00(ActivityThread.java:135)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:136)
      at android.app.ActivityThread.main(ActivityThread.java:5045)
      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)

我的Build.gradle:

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile project(':searchlibrary')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:palette-v7:24.1.1'
compile 'com.google.code.gson:gson:2.6.2'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.10.0'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-messaging:9.4.0'

谁能帮我解决这个问题?

从 SDK 管理器下载最新的 Google Play 服务。 并在 Build.gradle

中编译最新的 Google Play 服务

你的情况

从您的 build.gradle 文件中删除此依赖项

compile 'com.google.android.gms:play-services:9.4.0'

并像这样单独添加一个

compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'

这应该可以解决您的问题。

在 gradle 的顶层:

buildscript {
    repositories {
        jcenter()
}
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

在应用级别 gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.firebase:firebase-messaging:9.4.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.firebase:firebase-client-android:2.3.1' 
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.firebase:firebase-client-android:2.3.1'
}
apply plugin: 'com.google.gms.google-services'