FirebaseInstanceIdReceiver ClassNotFoundException when receiving notifications

EarlBalmesEarlBalmes USMember ✭✭

I'm getting an exception when I'm trying to send a notification to my device using Firebase. The Firebase token and initialization seems to go smoothly, but it just crashes after I send the notification from the console . This is in Release mode with ProGuard and Multi-dex enabled (I have a feeling it's related to the multi-dex).

[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: {APPLICATION-NAME}, PID: 30458
[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceIdReceiver" on path: DexPathList[[zip file "/data/app/{APPLICATION-NAME}-1/base.apk"],nativeLibraryDirectories=[/data/app/{APPLICATION-NAME}-1/lib/arm, /data/app/{APPLICATION-NAME}-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
[AndroidRuntime]    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3681)
[AndroidRuntime]    at android.app.ActivityThread.access$2000(ActivityThread.java:229)
[AndroidRuntime]    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1903)
[AndroidRuntime]    at android.os.Handler.dispatchMessage(Handler.java:102)
[AndroidRuntime]    at android.os.Looper.loop(Looper.java:148)
[AndroidRuntime]    at android.app.ActivityThread.main(ActivityThread.java:7325)
[AndroidRuntime]    at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime]    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
[AndroidRuntime]    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceIdReceiver" on path: DexPathList[[zip file "/data/app/{APPLICATION-NAME}-1/base.apk"],nativeLibraryDirectories=[/data/app/{APPLICATION-NAME}-1/lib/arm, /data/app/{APPLICATION-NAME}-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
[AndroidRuntime]    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
[AndroidRuntime]    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
[AndroidRuntime]    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
[AndroidRuntime]    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3676)
[AndroidRuntime]    ... 8 more
[AndroidRuntime]    Suppressed: java.lang.ClassNotFoundException: com.google.firebase.iid.FirebaseInstanceIdReceiver
[AndroidRuntime]        at java.lang.Class.classForName(Native Method)
[AndroidRuntime]        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
[AndroidRuntime]        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
[AndroidRuntime]        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
[AndroidRuntime]        ... 10 more
[AndroidRuntime]    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
[Process] Sending signal. PID: 30458 SIG: 9

Best Answer

Answers

  • EarlBalmesEarlBalmes USMember ✭✭

    I've done some more digging into this problem, and it turns out that this class isn't being referenced in my classes.dex and classes2.dex file for Release mode, although it works in Debug. I've checked my multidex.keep file for both Debug and Release modes and they're identical.

    I also found out that it works when I set the Linker options to "Don't Link", but this increases my APK size by a large amount. Is there anyway that I can keep using the Linker and get rid of this error?

  • ChrisAhernChrisAhern USMember ✭✭

    I've run into this exact issue! As you say if linking is set to None it works at the expense of a much bigger APK.

  • ChrisAhernChrisAhern USMember ✭✭

    Still working away at this. Have you made any progress? The next logical step I did was add Xamarin.Firebase.Iid to the "Skip linking assemblies" in the linker properties. Unfortunately that made no difference. I even tried adding all the Firebase assemblies to this list but that didn't help either. I suspect the problem is deeper in the framework and the specifying of linking options is being ignored and shouldn't be necessary.

    I'm now looking at regressing to GCM .. I'll let you know how that goes :#

  • ChrisAhernChrisAhern USMember ✭✭

    Thank you - that was it!!! I hadn't got to suspecting ProGuard (although in hind sight I should've looked at it more closely) because it worked fine with no linking and with ProGuard being downstream, reasoned it could only work with whatever it got. Now I know it's smarter than that. I could tell about the hours I've spent on this but I won't! :neutral:

    In any case, thanks a ton! :smile:

  • RonnieCyrierRonnieCyrier USMember ✭✭

    Hi there. Been banging my head against the wall

    @AlbertK said:
    Did you enabled Proguard ? if so, add the following into ProGuard.cfg file.

    -dontwarn com.google.android.gms.**
    -keep class com.google.android.gms.** { *; }
    -keep class com.google.firebase.** { *; } 
    

    This solved the problem. Does it hurt to have a _dontwarn com.google.firebase.**?

    One thing to note. Make sure you save cfg file as UTF-8 and NOT UTF-8 BOM
    If you do not, you'll get the dreaded java.exe exited with code 1 error.

Sign In or Register to comment.