I implemented the new FCM on the app following the steps on the FCM web.
Now, I'm trying to run the app, but when I try it, the app crash with this error:
05-30 12:28:45.788 3002-3002/es.in2.otr.app.im E/AndroidRuntime: FATAL EXCEPTION: main
Process: es.in2.otr.app.im, PID: 3002
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.res.Resources.getResourcePackageName(int)' on a null object reference
at android.app.ActivityThread.installProvider(ActivityThread.java:6765)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6357)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6297)
at android.app.ActivityThread.access$1800(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.res.Resources.getResourcePackageName(int)' on a null object reference
at com.google.android.gms.common.internal.zzah.<init>(Unknown Source)
at com.google.firebase.FirebaseOptions.fromResource(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:1789)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1764)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6762)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6357)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6297)
at android.app.ActivityThread.access$1800(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
As I can see, thre method is trying to get some value, where is null.
I searched for solutions, and found this post in SO. --> Unable to get provider com.google.firebase.provider.FirebaseInitProvider
As solution they said to add the applicationId to the gradle build project file, but I got it:
defaultConfig {
applicationId "es.in2.otr.app.im"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
testApplicationId "es.in2.otr.app.im.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
And stills crashing.
Is there some workaorund or solution to this problem?
Add the line
compile 'com.android.support:multidex:1.0.1'
to your dependencies (or simply removemultiDexEnabled true
if not required)Add this attribute to the application tag in manifest:
If you already have a custom application class defined in Android Manifest, extend it from MultiDexApplication instead of Application
This works for me!
I had the same problem. After adding the aplicationId i noticed that there were 2 apps installed on my device. I think it somehow changed the package name of the app leading the device to understand that were two different apps.
So i uninstalled the two versions and then it worked.
ps: The command line is not launching the app normally. It says: "Launching application...LAUNCH SUCCESS" but the app is never launched, i have to open it manually
EDIT: Just found out that i was type a wrong application id, now it works properly