E / AndroidRuntime:致命例外:Firebase-MyFirebaseMessagingService Android Studio

时间:2018-09-29 11:02:47

标签: java android firebase android-studio

我的应用尝试从Firebase云消息传递接收通知消息时崩溃。

这是错误日志:

E/AndroidRuntime: FATAL EXCEPTION: Firebase-MyFirebaseMessagingService
                  Process: com.seesharp.taxibyeuser, PID: 31273
                  java.lang.NoSuchMethodError: No static method zzc(Landroid/content/Context;)Lcom/google/firebase/iid/zzs; in class Lcom/google/firebase/iid/zzs; or its super classes (declaration of 'com.google.firebase.iid.zzs' appears in /data/app/com.seesharp.taxibyeuser-Kx-umRNM53Ly-ccAR442PQ==/split_lib_dependencies_apk.apk)
                      at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:117)
                      at com.google.firebase.iid.zzg.run(Unknown Source:26)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
                      at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
                      at java.lang.Thread.run(Thread.java:764)

我在google和stackoverflow中进行了搜索,但是所有解决方案都没有用。但是,在搜索过程中,我发现问题出在我的build.gradle上,但我不知道问题出在哪里以及如何解决。

这是App build.gradle的内容:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }




}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}





android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.seesharp.taxibyeuser"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 9
        versionName "1.9"
        multiDexEnabled true
        testInstrumentationRunner "android.support.home_fragment.runner.AndroidJUnitRunner"
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }
    dexOptions {
        preDexLibraries = false
    }

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

dependencies {
    implementation ('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.13.0') {
        transitive = true
    }
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.13.0'
    implementation 'com.google.firebase:firebase-auth:15.1.0'
    implementation 'com.google.firebase:firebase-messaging:15.0.2'
    implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
    implementation 'com.github.TheBrownArrow:PermissionManager:1.0.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'gun0912.ted:tedbottompicker:1.1.0'
    implementation 'com.akexorcist:googledirectionlibrary:1.0.5'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-places:15.0.1'
    implementation 'com.google.android.gms:play-services-base:15.0.1'
    implementation 'com.google.firebase:firebase-database:15.0.1'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation ('com.crashlytics.sdk.android:crashlytics:2.9.2@aar') {
        transitive = true;
    }

}

apply plugin: 'com.google.gms.google-services'

这是项目build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3"
        classpath 'com.google.gms:google-services:3.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
        maven {
            url 'https://maven.google.com'
        }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

如果您需要有关该项目的更多信息,请告诉我您要我发布的内容。

请,我需要使其工作。

1 个答案:

答案 0 :(得分:1)

  

java.lang。 NoSuchMethodError 无静态方法   zzc(Landroid / content / Context;)Lcom / google / firebase / iid / zzs

尝试更新到最新版本的Firebase:

implementation 'com.google.firebase:firebase-core:16.0.3'
...
..

Google服务:

classpath 'com.google.gms:google-services:4.1.0'

此外,您用于Firebase的版本至少应该相同。例如:

implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'   

只有少数依赖项可能具有不同的版本。例如:

implementation 'com.google.firebase:firebase-messaging:17.3.0'

检查并阅读: https://firebase.google.com/docs/android/setup#available_libraries