Firebase API initialization failure,java.lang.reflect.InvocationTargetException

巧了我就是萌 提交于 2019-12-08 02:43:48

问题


I am using firebase auth, database and storage services in my app. It was working fine previously. I have added firebase cloud messaging setup as described in docs. But app crashes at runtime.I investigated the issue for about 4 hours and tried different solutions. Like keeping all libs version same, changing appcompat library version and change app to multidex.But nothing helped. Below is my gradle dependencies:

compile('com.digits.sdk.android:digits:2.0.6@aar') {
    transitive = true;
}

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:percent:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
testCompile 'junit:junit:4.12'

//Firebase
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebaseui:firebase-ui-storage:0.6.0'

On compiling app produces following exception:

05-02 20:05:55.746 31927-31927/com.apponative.committeeapp A/FirebaseApp: Firebase API initialization failure.
  java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      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.initializeApp(Unknown Source)
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5015)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
      at android.app.ActivityThread.access$1500(ActivityThread.java:151)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
      at android.os.Handler.dispatchMessage(Handler.java:110)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:5299)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.NoSuchMethodError: com.google.android.gms.common.api.zzc.<init>
      at com.google.android.gms.internal.zzbiu.<init>(Unknown Source)
      at com.google.android.gms.internal.zzbjc.zza(Unknown Source)
      at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
      at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
      at com.google.android.gms.internal.zzbkg.<init>(Unknown Source)
      at com.google.firebase.auth.FirebaseAuth.zzd(Unknown Source)
      at com.google.firebase.auth.FirebaseAuth.zzc(Unknown Source)
      at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      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.initializeApp(Unknown Source) 
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1656) 
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1627) 
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
      at android.app.ActivityThread.installProvider(ActivityThread.java:5015) 
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522) 
      at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381) 
      at android.os.Handler.dispatchMessage(Handler.java:110) 
      at android.os.Looper.loop(Looper.java:193) 
      at android.app.ActivityThread.main(ActivityThread.java:5299) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
      at dalvik.system.NativeStart.main(Native Method) 
05-02 20:05:55.774 31927-31927/com.apponative.committeeapp A/FirebaseApp: Firebase API initialization failure.
  java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      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.initializeApp(Unknown Source)
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5015)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
      at android.app.ActivityThread.access$1500(ActivityThread.java:151)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
      at android.os.Handler.dispatchMessage(Handler.java:110)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:5299)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.NoSuchMethodError: com.google.android.gms.common.util.zzx.getNoBackupFilesDir
      at com.google.firebase.iid.zzh.zzeG(Unknown Source)
      at com.google.firebase.iid.zzh.<init>(Unknown Source)
      at com.google.firebase.iid.zzh.<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.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      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.initializeApp(Unknown Source) 
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1656) 
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1627) 
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
      at android.app.ActivityThread.installProvider(ActivityThread.java:5015) 
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522) 
      at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381) 
      at android.os.Handler.dispatchMessage(Handler.java:110) 
      at android.os.Looper.loop(Looper.java:193) 
      at android.app.ActivityThread.main(ActivityThread.java:5299) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
      at dalvik.system.NativeStart.main(Native Method) 
05-02 20:05:55.818 31927-31927/com.apponative.committeeapp A/FirebaseApp: Firebase API initialization failure.
  java.lang.reflect.InvocationTargetException
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      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.initializeApp(Unknown Source)
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5015)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
      at android.app.ActivityThread.access$1500(ActivityThread.java:151)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
      at android.os.Handler.dispatchMessage(Handler.java:110)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:5299)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:515)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
      at dalvik.system.NativeStart.main(Native Method)
   Caused by: java.lang.NoSuchMethodError: com.google.android.gms.internal.zzapn.zzb
      at com.google.android.gms.internal.zzbku.<clinit>(Unknown Source)
      at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source)
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:515) 
      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.initializeApp(Unknown Source) 
      at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source) 
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1656) 
      at android.content.ContentProvider.attachInfo(ContentProvider.java:1627) 
      at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
      at android.app.ActivityThread.installProvider(ActivityThread.java:5015) 
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522) 
      at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381) 
      at android.os.Handler.dispatchMessage(Handler.java:110) 
      at android.os.Looper.loop(Looper.java:193) 
      at android.app.ActivityThread.main(ActivityThread.java:5299) 
      at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)   at dalvik.system.NativeStart.main(Native Method) 
05-02 20:05:55.845 31927-31927/com.apponative.committeeapp A/FirebaseApp: Firebase API initialization failure.
  java.lang.reflect.InvocationTargetException  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  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.initializeApp(Unknown Source)   at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)   at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)  at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)   at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)  at android.app.ActivityThread.installProvider(ActivityThread.java:5015)  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589)at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)  at android.app.ActivityThread.access$1500(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)  at android.os.Handler.dispatchMessage(Handler.java:110)  at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5299)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.VerifyError: com/google/android/gms/internal/zzatp at com.google.android.gms.measurement.AppMeasurement.getInstance(Unknown Source) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515)  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.initializeApp(Unknown Source)  at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)  at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)  at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)  at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) at android.app.ActivityThread.installProvider(ActivityThread.java:5015)  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)  at android.app.ActivityThread.access$1500(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381) at android.os.Handler.dispatchMessage(Handler.java:110)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:5299) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645) 
      at dalvik.system.NativeStart.main(Native Method) 
05-02 20:05:56.468 31927-31927/com.apponative.committeeapp E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
05-02 20:05:56.842 31927-31927/com.apponative.committeeapp E/AndroidRuntime: FATAL EXCEPTION: main
     Process: com.apponative.committeeapp, PID: 31927
     java.lang.NoSuchMethodError: com.google.android.gms.common.api.zzc.<init>       at com.google.android.gms.internal.zzbiu.<init>(Unknown Source)                at com.google.android.gms.internal.zzbjc.zza(Unknown Source)                  at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)                 at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)               at com.google.android.gms.internal.zzbkg.<init>(Unknown Source)               at com.google.firebase.auth.FirebaseAuth.zzd(Unknown Source)                   at com.google.firebase.auth.FirebaseAuth.zzc(Unknown Source)                  at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)               at com.apponative.committeeapp.firebase.FireBaseAuth.fireBaseAuth(FireBaseAuth.java:42)             

回答1:


You should not include com.google.android.gms:play-services:10.0.1 as a dependency. This adds ALL the Google Play Services APIs to your build and will probably require you to use MultiDex. Instead, follow the directions provided in the Setup Guide in the section titled Selectively compiling APIs into your executable to add as depencies only the specific APIs that you actually use.

Also, the version of the Firebase UI libraries that you include must be compatible with the version of Firebase libraries. The table of compatible versions is include in the Firebase UI documentation. For Firebase APIs version 10.0.1, you should use firebase-ui-storage:1.1.1



来源:https://stackoverflow.com/questions/43741741/firebase-api-initialization-failure-java-lang-reflect-invocationtargetexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!