FCM快速入门应用已与IllegalAccessError崩溃

时间:2017-08-04 07:05:50

标签: android firebase push-notification firebase-cloud-messaging

我尝试使用Firebase云消息传递(FCM)在Androind上实施推送通知。所以我从GitHab(https://github.com/firebase/quickstart-android/tree/master/messaging/)导入了谷歌的快速入门项目。我在Android上运行应用程序。但该应用程序崩溃了。详细环境和错误消息如下。请看看这个问题。

环境

Android Studio 2.3.3

项目级别build.gradle

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.1.0'  // Added MODULE_VERSION = "9.0.0"

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

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        google()
    }
}

App level build.gradle

apply plugin: 'com.android.application'
check.dependsOn 'assembleDebugAndroidTest'

android {
    compileSdkVersion 26
    buildToolsVersion '25.0.3'

    defaultConfig {
        applicationId "com.google.firebase.quickstart.fcm"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    packagingOptions {
        exclude 'LICENSE.txt'
    }

    lintOptions {
        abortOnError false
    }
}

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:26.0.0-beta2'
}

repositories {
    maven { url 'https://maven.google.com' }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:26.0.0-beta2'

    compile 'com.android.support:animated-vector-drawable:26.0.0-beta2'
    compile 'com.android.support:support-compat:26.0.0-beta2'

    // compile 'com.google.firebase:firebase-core:10.2.1'  // Added in accordance with https://firebase.google.com/docs/android/setup but conflicted
    compile 'com.google.firebase:firebase-core:9.0.0'


    // compile 'com.google.firebase:firebase-messaging:11.0.1'  // Added in accordance with https://firebase.google.com/docs/android/setup but conflicted
    compile 'com.google.firebase:firebase-messaging:9.0.0'

    compile 'com.firebase:firebase-jobdispatcher:0.6.0'

    // Testing dependencies
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support.test:runner:0.5'
    androidTestCompile 'com.android.support:support-annotations:25.3.1'
}

apply plugin: 'com.google.gms.google-services'  // Added in accordance with https://firebase.google.com/docs/android/setup

的logcat

08-04 16:01:16.749 6218-6218/? I/art: Late-enabling -Xcheck:jni
08-04 16:01:16.749 6218-6218/? I/art: Reinit property: dalvik.vm.checkjni= false
08-04 16:01:16.805 6218-6218/com.google.firebase.quickstart.fcm W/System: ClassLoader referenced unknown path: /data/app/com.google.firebase.quickstart.fcm-2/lib/arm64
08-04 16:01:16.846 6218-6218/com.google.firebase.quickstart.fcm E/FirebaseApp: Firebase API initialization failure.
                                                                               java.lang.reflect.InvocationTargetException
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.google.firebase.FirebaseApp.zza(Unknown Source)
                                                                                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                                                                                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
                                                                                   at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
                                                                                   at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
                                                                                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
                                                                                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
                                                                                   at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
                                                                                   at android.app.ActivityThread.installProvider(ActivityThread.java:6257)
                                                                                   at android.app.ActivityThread.installContentProviders(ActivityThread.java:5775)
                                                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5693)
                                                                                   at android.app.ActivityThread.-wrap2(ActivityThread.java)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:105)
                                                                                   at android.os.Looper.loop(Looper.java:156)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:6577)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
                                                                                Caused by: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.google.firebase.quickstart.fcm-2/base.apk)
                                                                                   at com.google.firebase.iid.zzg.zzeC(Unknown Source)
                                                                                   at com.google.firebase.iid.zzg.<init>(Unknown Source)
                                                                                   at com.google.firebase.iid.zzg.<init>(Unknown Source)
                                                                                   at com.google.firebase.iid.zzd.zzb(Unknown Source)
                                                                                   at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)?
                                                                                   at com.google.firebase.FirebaseApp.zza(Unknown Source)?
                                                                                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)?
                                                                                   at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)?
                                                                                   at com.google.firebase.FirebaseApp.zzbu(Unknown Source)?
                                                                                   at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)?
                                                                                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)?
                                                                                   at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)?
                                                                                   at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)?
                                                                                   at android.app.ActivityThread.installProvider(ActivityThread.java:6257)?
                                                                                   at android.app.ActivityThread.installContentProviders(ActivityThread.java:5775)?
                                                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5693)?
                                                                                   at android.app.ActivityThread.-wrap2(ActivityThread.java)?
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)?
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:105)?
                                                                                   at android.os.Looper.loop(Looper.java:156)?
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:6577)?
                                                                                   at java.lang.reflect.Method.invoke(Native Method)?
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)?
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)?
08-04 16:01:16.857 6218-6218/com.google.firebase.quickstart.fcm I/FA: App measurement is starting up, version: 9080
08-04 16:01:16.857 6218-6218/com.google.firebase.quickstart.fcm I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
08-04 16:01:16.874 6218-6218/com.google.firebase.quickstart.fcm I/FirebaseInitProvider: FirebaseApp initialization successful
08-04 16:01:16.884 6218-6218/com.google.firebase.quickstart.fcm I/HwCust: Constructor found for class android.app.HwCustActivityImpl
08-04 16:01:16.912 6218-6218/com.google.firebase.quickstart.fcm W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-04 16:01:16.997 6218-6218/com.google.firebase.quickstart.fcm I/HwSecImmHelper: mSecurityInputMethodService is null
08-04 16:01:17.002 6218-6218/com.google.firebase.quickstart.fcm I/HwPointEventFilter: do not support AFT because of no config
08-04 16:01:17.068 6218-6258/com.google.firebase.quickstart.fcm I/OpenGLRenderer: Initialized EGL, version 1.4
08-04 16:01:17.079 6218-6258/com.google.firebase.quickstart.fcm W/linker: /vendor/lib64/libhwuibp.so: unused DT entry: type 0xf arg 0xe3a
08-04 16:01:17.160 6218-6247/com.google.firebase.quickstart.fcm E/FA: Task exception on worker thread: java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.google.firebase.quickstart.fcm-2/base.apk): com.google.android.gms.measurement.internal.zzt.zzEd(Unknown Source)
08-04 16:01:22.011 6218-6218/com.google.firebase.quickstart.fcm W/IInputConnectionWrapper: reportFullscreenMode on inexistent InputConnection
08-04 16:01:23.141 6218-6218/com.google.firebase.quickstart.fcm I/hwaps: JNI_OnLoad
08-04 16:01:23.289 6218-6218/com.google.firebase.quickstart.fcm E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  Process: com.google.firebase.quickstart.fcm, PID: 6218
                                                                                  java.lang.IllegalAccessError: Method 'void android.support.v4.content.ContextCompat.<init>()' is inaccessible to class 'com.google.firebase.iid.zzg' (declaration of 'com.google.firebase.iid.zzg' appears in /data/app/com.google.firebase.quickstart.fcm-2/base.apk)
                                                                                      at com.google.firebase.iid.zzg.zzeC(Unknown Source)
                                                                                      at com.google.firebase.iid.zzg.<init>(Unknown Source)
                                                                                      at com.google.firebase.iid.zzg.<init>(Unknown Source)
                                                                                      at com.google.firebase.iid.zzd.zzb(Unknown Source)
                                                                                      at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
                                                                                      at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
                                                                                      at com.google.firebase.quickstart.fcm.MainActivity$2.onClick(MainActivity.java:92)
                                                                                      at android.view.View.performClick(View.java:5647)
                                                                                      at android.view.View$PerformClick.run(View.java:22465)
                                                                                      at android.os.Handler.handleCallback(Handler.java:761)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                                      at android.os.Looper.loop(Looper.java:156)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:6577)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
08-04 16:01:23.306 6218-6218/com.google.firebase.quickstart.fcm I/Process: Sending signal. PID: 6218 SIG: 9

0 个答案:

没有答案