我在我的Android应用中集成了Firebase云消息传递服务。目前,我的应用程序扩展了Application类(名为MainApplication),并在清单应用程序标记中声明。
我已按照所有说明启用Firebase云消息传递。当我运行应用程序时,我会在堆栈跟踪下面收到
04-03 17:05:16.099 20911-20911/<package_name> E/FA: Failed to load metadata: Package name not found: android.content.pm.PackageManager$NameNotFoundException: : com.google.android.gms.internal.zzadf.getApplicationInfo(Unknown Source)
04-03 17:05:16.099 20911-20911/<package_name> E/FA: Scheduler not set. Not logging error/warn
04-03 17:05:16.099 20911-20911/<package_name> E/FA: Failed to load metadata: Package name not found: android.content.pm.PackageManager$NameNotFoundException: : com.google.android.gms.internal.zzadf.getApplicationInfo(Unknown Source)
04-03 17:05:16.099 20911-20911/<package_name> E/FA: Scheduler not set. Not logging error/warn
04-03 17:05:16.100 20911-20911/<package_name> V/FA: Collection enabled
04-03 17:05:16.100 20911-20911/<package_name> V/FA: App package, google app id: 1:744836320047:android:a611bb33ea5170ee
04-03 17:05:16.100 20911-20911/<package_name> I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app
04-03 17:05:16.100 20911-20911/<package_name> D/FA: Debug-level message logging enabled
04-03 17:05:16.103 20911-20911/<package_name> 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.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5262)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4847)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4787)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:234)
at android.app.ActivityThread.main(ActivityThread.java:5526)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: Permission Denial: getIntentSender() from pid=20911, uid=10252, (need uid=-1) is not allowed to send as package
at android.os.Parcel.readException(Parcel.java:1627)
at android.os.Parcel.readException(Parcel.java:1579)
at android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:4032)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:531)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:515)
at com.google.android.gms.internal.zzaup.zzpE(Unknown Source)
at com.google.android.gms.internal.zzaup.zzmS(Unknown Source)
at com.google.android.gms.internal.zzauh.initialize(Unknown Source)
at com.google.android.gms.internal.zzaue.<init>(Unknown Source)
at com.google.android.gms.internal.zzaui.zzMP(Unknown Source)
at com.google.android.gms.internal.zzaue.zzbM(Unknown Source)
at com.google.android.gms.measurement.AppMeasurement.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.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1748)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1723)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5262)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4847)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4787)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:234)
at android.app.ActivityThread.main(ActivityThread.java:5526)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-03 17:05:16.105 20911-20911/<package_name> I/FirebaseInitProvider: FirebaseApp initialization successful
甚至没有生成令牌。但是当我从清单中的应用程序标签中删除应用程序名称属性时,即不在清单中指定我的应用程序类。上面的错误消失了,我得到了令牌。
我试过调用
FirebaseApp.initializeApp(this);
在我的应用程序类的onCreate中,但仍然收到此错误。 目前我在Firebase版本下使用,但也尝试使用早期版本,但仍然收到错误堆栈。
compile 'com.google.firebase:firebase-messaging:10.2.1'
删除扩展的Application类以使用Firebase没有意义。不确定需要做什么。
由于