使用Firebase的“NoClassDefFoundError:com.google.firebase.FirebaseOptions”

时间:2016-07-29 11:46:55

标签: android firebase android-gradle firebase-cloud-messaging

大家好我正在构建一个应用程序,我正在使用Firebase云消息传递和融合位置提供程序,当我将融合位置提供程序放入应用程序时,我收到Firebase的此错误:

07-29 13:40:06.590 12635-12635/com.telnet.asp E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java)
at android.content.ContentProvider.attachInfo(ContentProvider.java)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java)
at android.app.ActivityThread.installContentProviders(ActivityThread.java)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java)
at android.app.ActivityThread.access$1400(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(Native Method)

这是我的Gradle:

android {
    dexOptions {
        incremental = true;
        javaMaxHeapSize "4g"
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    compileOptions.incremental = false

    defaultConfig {
        applicationId "com.telnet.asp"

        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        multiDexEnabled true

    }

    dataBinding {
        enabled = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        apt 'com.google.dagger:dagger-compiler:2.2'
        provided 'javax.annotation:jsr250-api:1.0'
        compile project(path: ':domain')
        compile project(path: ':data')
        compile 'com.android.support:appcompat-v7:23.4.0'
        compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0-rc2'
        compile 'com.android.support:design:23.4.0'
        compile 'javax.inject:javax.inject:1'
        compile 'com.squareup.retrofit2:retrofit:2.1.0'
        compile 'com.squareup.retrofit2:converter-gson:2.1.0'
        compile 'io.reactivex:rxandroid:1.2.1'
        compile 'io.reactivex:rxjava:1.1.6'
        compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
        compile 'com.google.dagger:dagger:2.2'
        compile 'com.android.support:support-v4:23.4.0'
        compile 'com.jakewharton:butterknife:6.1.0'
        compile 'net.danlew:android.joda:2.9.4.1'
        compile 'com.android.support:percent:23.4.0'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.google.firebase:firebase-messaging:9.0.0'
        compile 'com.google.android.gms:play-services:9.0.0'
     }
    apply plugin: 'com.google.gms.google-services'

我的错误是什么?如何解决? 编辑:当我将谷歌播放服务降级到8.4.0时,我收到此错误:

 Error:Execution failed for task ':presentation:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.

1 个答案:

答案 0 :(得分:0)

我认为您必须使用'com.google.firebase:firebase-ads:9.0.2'代替播放服务'com.google.android.gms:play-services:9.0.0'以下是信息https://firebase.google.com/docs/android/setup#add_the_sdk