我正在获取FirebaseApp:Firebase API初始化失败。重命名应用程序软件包名称后出现错误,但使用原始软件包名称可以正常工作
我为新程序包以及新的google-json文件创建了新的firebase应用。
错误日志:
09-07 17:39:56.940 10181-10181/com.upliftapp D/FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
09-07 17:39:56.952 10181-10181/com.upliftapp E/FirebaseApp: Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(SourceFile:739)
at com.google.firebase.FirebaseApp.zze(SourceFile:707)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:328)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:294)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:281)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(SourceFile:37)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(SourceFile:31)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zztv;
at com.google.firebase.crash.internal.config.flag.Flags.<clinit>(Unknown Source:10)
at com.google.firebase.crash.internal.config.flag.Flags.initialize(Unknown Source:0)
at com.google.firebase.crash.FirebaseCrash.getInstance(Unknown Source:4)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(SourceFile:739)
at com.google.firebase.FirebaseApp.zze(SourceFile:707)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:328)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:294)
at com.google.firebase.FirebaseApp.initializeApp(SourceFile:281)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(SourceFile:37)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1917)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1892)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(SourceFile:31)
at android.app.ActivityThread.installProvider(ActivityThread.java:6239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
09-07 17:39:56.953 10181-10181/com.upliftapp E/FirebaseApp: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zztv" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/base.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_dependencies_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_0_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_1_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_2_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_3_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_4_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_5_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_6_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_7_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_8_apk.apk", zip file "/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/base.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_dependencies_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_0_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_1_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_2_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_3_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_4_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_5_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_6_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_7_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_8_apk.apk!/lib/x86, /data/app/com.upliftapp-loT5KzpsPyXgUB1ROEaJ7w==/split_lib_slice_9_apk.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 24 more
09-07 17:39:56.991 10181-10181/com.upliftapp V/FA: Registered activity lifecycle callback
09-07 17:39:56.993 10181-10181/com.upliftapp I/FirebaseInitProvider: FirebaseApp initialization successful
09-07 17:39:57.040 10181-10181/com.upliftapp E/com.facebook.internal.AttributionIdentifiers: getAttributionIdentifiers should not be called from the main thread
09-07 17:39:57.055 10181-10198/com.upliftapp I/zygote: Background concurrent copying GC freed 13187(4MB) AllocSpace objects, 3(56KB) LOS objects, 52% free, 1392KB/2MB, paused 329us total 107.573ms
09-07 17:39:57.094 10181-10216/com.upliftapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-07 17:39:57.158 10181-10215/com.upliftapp V/FA: Collection enabled
App package, google app id: com.upliftapp, 1:456357737763:android:898ccf45fd84a88b
09-07 17:39:57.158 10181-10215/com.upliftapp I/FA: App measurement is starting up, version: 12451
To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.upliftapp
09-07 17:39:57.158 10181-10215/com.upliftapp D/FA: Debug-level message logging enabled
09-07 17:39:57.176 10181-10215/com.upliftapp V/FA: Connecting to remote service
09-07 17:39:57.195 10181-10215/com.upliftapp V/FA: Connection attempt already in progress
09-07 17:40:27.011 10181-10212/com.upliftapp E/FirebaseInstanceId: Token retrieval failed: SERVICE_NOT_AVAILABLE
09-07 17:40:34.157 10181-10192/com.upliftapp I/zygote: Thread[3,tid=10192,WaitingInMainSignalCatcherLoop,Thread*=0xe3059c00,peer=0x16440ad0,"Signal Catcher"]: reacting to signal 3
09-07 17:40:34.183 10181-10192/com.upliftapp I/zygote: Wrote stack traces to '[tombstoned]'
这是我得到的日志。
答案 0 :(得分:1)
当您首次将Android应用程序连接到Firebase应用程序以启用FCM时,已获得名为google-services.json
的文件。该文件包含您应用的程序包名称,并具有连接到Firebase所需的信息。
如果您更改了程序包名称,请打开并使用新的程序包名称编辑该文件。或转到Firebase控制台并使用正确的程序包名称获取一个新的google-services.json
文件。
这就是为什么旧的不起作用而新的不起作用