quickstart-android: Firebase API initialization failure. (java.lang.IncompatibleClassChangeError)

Hi,

    FirebaseMessaging.getInstance().subscribeToTopic("global");

this line causing en error:

05-26 15:52:42.551 11612-11612/com.lotram.uygulamacoapp A/FirebaseApp: Firebase API initialization failure. java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) 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:1714) at android.content.ContentProvider.attachInfo(ContentProvider.java:1683) at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) at android.app.ActivityThread.installProvider(ActivityThread.java:5012) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4607) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4547) at android.app.ActivityThread.access$1500(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5272) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704) Caused by: java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar) 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 java.lang.reflect.Method.invoke(Method.java:372)  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:1714)  at android.content.ContentProvider.attachInfo(ContentProvider.java:1683)  at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)  at android.app.ActivityThread.installProvider(ActivityThread.java:5012)  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4607)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4547)  at android.app.ActivityThread.access$1500(ActivityThread.java:148)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5272)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)  05-26 15:52:43.401 11612-11612/com.lotram.uygulamacoapp E/ApkAssets: Error while loading asset assets/icudtl.dat: java.io.FileNotFoundException: assets/icudtl.dat 05-26 15:52:44.017 11612-11612/com.lotram.uygulamacoapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.lotram.uygulamacoapp, PID: 11612 java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar) 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.messaging.FirebaseMessaging.getInstance(Unknown Source) at com.lotram.uygulamacoapp.MainActivity.onCreate(MainActivity.java:51) at android.app.Activity.performCreate(Activity.java:5977) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365) at android.app.ActivityThread.access$800(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5272) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704) 05-26 15:59:59.507 17613-17613/com.lotram.uygulamacoapp A/FirebaseApp: Firebase API initialization failure. java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) 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:1714) at android.content.ContentProvider.attachInfo(ContentProvider.java:1683) at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) at android.app.ActivityThread.installProvider(ActivityThread.java:5012) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4607) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4547) at android.app.ActivityThread.access$1500(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5272) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704) Caused by: java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar) 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 java.lang.reflect.Method.invoke(Method.java:372)  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:1714)  at android.content.ContentProvider.attachInfo(ContentProvider.java:1683)  at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)  at android.app.ActivityThread.installProvider(ActivityThread.java:5012)  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4607)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4547)  at android.app.ActivityThread.access$1500(ActivityThread.java:148)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5272)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)  05-26 16:00:00.275 17613-17613/com.lotram.uygulamacoapp E/ApkAssets: Error while loading asset assets/icudtl.dat: java.io.FileNotFoundException: assets/icudtl.dat 05-26 16:00:00.694 17613-17613/com.lotram.uygulamacoapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.lotram.uygulamacoapp, PID: 17613 java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar) 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.messaging.FirebaseMessaging.getInstance(Unknown Source) at com.lotram.uygulamacoapp.MainActivity.onCreate(MainActivity.java:64) at android.app.Activity.performCreate(Activity.java:5977) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365) at android.app.ActivityThread.access$800(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5272) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

my app/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.lotram.uygulamacoapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    maven {
        url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile 'org.xwalk:xwalk_core_library:17.46.448.10'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'org.apache.commons:commons-io:1.3.2'

    compile 'com.google.firebase:firebase-messaging:9.0.0'
}

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

and my project/build.gradle

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

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

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (4 by maintainers)

Most upvoted comments

@iboylmz try updating your dependency to compile 'com.google.firebase:firebase-messaging:9.0.2', I believe this bug was fixed in the patches between 9.0.0 and 9.0.2.

Hello @samtstern , the error still occurring with 9.0.2 Log:

07-06 15:26:57.485 3897-3897/ A/FirebaseApp: Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    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:1696)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
    at android.app.ActivityThread.installProvider(ActivityThread.java:5084)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4679)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4619)
    at android.app.ActivityThread.access$1500(ActivityThread.java:155)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5343)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: java.lang.IncompatibleClassChangeError: The method 'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' was expected to be of type virtual but instead was found to be of type direct (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
    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 java.lang.reflect.Method.invoke(Method.java:372) 
    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:1696) 
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1671) 
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
    at android.app.ActivityThread.installProvider(ActivityThread.java:5084) 
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4679) 
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4619) 
    at android.app.ActivityThread.access$1500(ActivityThread.java:155) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5343) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

Hi guys, I did the same problem and after for very searches I find the solution:

Update the dependencies of firebase in the build.gradle with 9.0.2 version compile ‘com.google.firebase:firebase-core:9.0.2’ compile ‘com.google.firebase:firebase-messaging:9.0.2’

This Resolved for me.

I got this error on 9.4.0 , same error. Could anybody help? Thanks

Hi @GiorgioNatili , thanks! Last day i just added firebase-core , then the error was gone.

@elsennov I solved it by adding the following dependencies to the app gradle file

    compile 'com.google.firebase:firebase-database:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.google.firebase:firebase-config:9.4.0'