【问题标题】:E/AndroidRuntime: FATAL EXCEPTION: Firebase-MyFirebaseMessagingService Android StudioE/AndroidRuntime: 致命例外: Firebase-MyFirebaseMessagingService Android Studio
【发布时间】:2019-03-05 04:24:11
【问题描述】:

我的应用在尝试从 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
}

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

拜托,我需要让它工作。

【问题讨论】:

    标签: java android firebase android-studio


    【解决方案1】:

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

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

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

    谷歌服务:

    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

    【讨论】:

    • gradle 尝试同步时出现以下错误:[[15.1.0,15.1.0]] 的各种其他库正在请求库 com.google.firebase:firebase-iid,但解析为 16.0.0。禁用插件并使用 ./gradlew :app:dependencies 检查你的依赖树。
    • 告诉过你所有的 firebase 依赖都应该更新......不仅仅是那些消息传递和身份验证依赖。这就是为什么你会收到这样的错误。 尝试全部更新
    猜你喜欢
    • 1970-01-01
    • 2020-08-07
    • 1970-01-01
    • 2015-04-16
    • 2022-10-25
    • 2022-01-17
    • 2019-01-10
    相关资源
    最近更新 更多