【问题标题】:AbstractMethodError with Firebase Cloud MessagingFirebase 云消息传递的 AbstractMethodError
【发布时间】:2016-09-27 12:28:46
【问题描述】:

我刚刚将我们应用的 GCM 更改为 FCM,并且还添加了 OneSignal。严格按照指南,甚至创建了一个新的侦听器服务来处理推送通知。

但是,即使没有侦听器,每当我收到推送时,应用程序都会崩溃并显示以下消息:

09-27 14:11:21.483 25361-25361/com.appname.here E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.appname.here, PID: 25361
java.lang.AbstractMethodError: abstract method "android.content.Intent com.google.firebase.iid.zzb.zzae(android.content.Intent)"
    at com.google.firebase.iid.zzb.onStartCommand(Unknown Source)
    at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3028)
    at android.app.ActivityThread.access$2200(ActivityThread.java:157)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1454)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5551)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

我已经从侦听器中删除了所有代码,即使这样,也会发生这种情况。

我是否以错误的方式实现了某些东西,或者我遗漏了什么?

Build.gradle:

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.0'
    }
}
apply plugin: 'com.android.application'

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

apply plugin: 'io.fabric'
apply plugin: 'android-apt'

android {
    lintOptions {
        checkReleaseBuilds false
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
    signingConfigs {
        release {

        }
        debug {

        }
    }
    compileSdkVersion 24
    buildToolsVersion '24.0.1'

    defaultConfig {
        applicationId "com.appname.here"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode getDate()
        versionName '2.1.0'
        multiDexEnabled true

        manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                                onesignal_app_id: "*******",
                                onesignal_google_project_number: "********"]
    }

    applicationVariants.all { variant ->
        def apkName = "appnamehere";
        apkName += "_" + variant.buildType.name + "_" + android.defaultConfig.versionName + "_" + android.defaultConfig.versionCode;
        variant.outputs.each { output ->
            output.outputFile = new File(output.outputFile.parent, apkName + ".apk");
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            debuggable true
            jniDebuggable true
            signingConfig signingConfigs.release
            renderscriptDebuggable true

        }
    }
    productFlavors {
        Live {
            signingConfig signingConfigs.release
        }
        Develop {
            signingConfig signingConfigs.release
            applicationIdSuffix ".develop"
        }
    }
}

def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyMMddHHmm')
    return formattedDate.toInteger()
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //compile project(':libphonenumber-5.9')
    compile project(':jaalee-sdk')
    compile project(':socialauth-android-3.2')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.4@aar') {
        transitive = true;
    }

    compile 'com.google.android.gms:play-services-gcm:9.6.1'
    compile 'com.onesignal:OneSignal:3.3.0@aar'

    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.android.support:customtabs:24.2.1'
//    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha5'
    compile 'com.google.android.gms:play-services-ads:9.6.1'
    compile 'com.google.android.gms:play-services-analytics:9.6.1'
    compile 'com.google.android.gms:play-services-auth:9.6.1'
    compile 'com.google.android.gms:play-services-identity:9.6.1'
    compile 'com.google.android.gms:play-services-location:9.6.1'
    compile 'com.google.android.gms:play-services-maps:9.6.1'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile 'com.googlecode.libphonenumber:libphonenumber:7.5.2'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.jakewharton:butterknife:8.2.1'
    compile 'com.thebluealliance:spectrum:0.5.0'
    compile 'com.joanzapata.iconify:android-iconify-entypo:2.2.2'
    compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.2.2'
    compile 'com.joanzapata.iconify:android-iconify-material:2.2.2'
    compile 'com.joanzapata.iconify:android-iconify-material-community:2.2.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jonathanfinerty.once:once:1.2.1'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'

    compile 'com.google.firebase:firebase-core:9.2.0'
    compile "com.google.firebase:firebase-messaging:9.0.2"

    compile 'com.github.clans:fab:1.6.4'                // Expandable floating button.
    compile 'com.androidadvance:topsnackbar:1.1.1'      // Top snackbar.
    compile 'com.baoyz.swipemenulistview:library:1.3.0' // Swipeable listview.
    compile 'me.relex:circleindicator:1.2.1@aar'        // Pager indicator.
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
}

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

crashlytics {
    enableNdk true
    androidNdkOut 'src/main/obj'
    androidNdkLibsOut 'src/main/libs'
}

【问题讨论】:

  • 请发布详细的 logcat 和你的 build.gradle
  • logcat 实际上就是这个条目,没有别的。我稍后会发布 app 模块的 build.gradle,我需要从中删除一些专有的和受 NDA 保护的东西。
  • @FrankVanPuffelen 请鼓励将此添加到文档中。

标签: android firebase firebase-cloud-messaging


【解决方案1】:

更新 Firebase 库的版本号以与其他 Google Play 服务库保持一致:

变化:

compile 'com.google.firebase:firebase-core:9.2.0'
compile "com.google.firebase:firebase-messaging:9.0.2"

收件人:

compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'

【讨论】:

  • 谢谢!现在试试。有趣的是,Android Studio 通常会通知包是否有更新,或者是否需要版本绑定。
  • 好吧,确实是问题所在。感谢您的帮助!
  • 绝对 - 这真的应该在文档中。
【解决方案2】:

当您在 wat 中定义待处理意图时会发生这种情况

        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

所以在上面我添加了 'this' 但应该有上下文或源 Activity

应该是这样的 解决方案 1

        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

解决方案 2

        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_ONE_SHOT);

在上面你需要通过一个参数或任何适合你的方法来传递上下文

【讨论】:

  • 请查看已接受的答案。主要问题是 Play Services 和 Firebase 库不在同一个版本上。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-10
  • 2018-02-06
  • 1970-01-01
相关资源
最近更新 更多