簡體   English   中英

Firebase 雲消息傳遞的 AbstractMethodError

[英]AbstractMethodError with Firebase Cloud Messaging

我剛剛將我們的應用程序的 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)

我已經從偵聽器中刪除了所有代碼,即使這樣,也會發生這種情況。

我是否以錯誤的方式實現了某些東西,或者我錯過了什么?

構建.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'
}

更新 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'

當您將在 wat 中定義待處理的意圖時會發生這種情況

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

所以在上面我添加了' this '但應該有一個上下文或一個源活動

它應該像解決方案 1

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

解決方案2

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

在上面,您需要通過參數或任何適合您的方法傳遞上下文

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM