Forum Xamarin.Android


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

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 java.lang.ClassNotFoundException: Didn't find class "" 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
[AndroidRuntime]    at$2000(
[AndroidRuntime]    at$H.handleMessage(
[AndroidRuntime]    at android.os.Handler.dispatchMessage(
[AndroidRuntime]    at android.os.Looper.loop(
[AndroidRuntime]    at
[AndroidRuntime]    at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime]    at$
[AndroidRuntime]    at
[AndroidRuntime] Caused by: java.lang.ClassNotFoundException: Didn't find class "" 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(
[AndroidRuntime]    at java.lang.ClassLoader.loadClass(
[AndroidRuntime]    at java.lang.ClassLoader.loadClass(
[AndroidRuntime]    at
[AndroidRuntime]    ... 8 more
[AndroidRuntime]    Suppressed: java.lang.ClassNotFoundException:
[AndroidRuntime]        at java.lang.Class.classForName(Native Method)
[AndroidRuntime]        at java.lang.BootClassLoader.findClass(
[AndroidRuntime]        at java.lang.BootClassLoader.loadClass(
[AndroidRuntime]        at java.lang.ClassLoader.loadClass(
[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


  • 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.

    -keep class** { *; }
    -keep class** { *; } 

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

    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.

  • msmanju1965msmanju1965 Member ✭✭

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

    -keep class** { *; }
    -keep class** { *; } 

    I have enable proguard and Created Progruard.cfg file in Android project folder and added thease lines, and make this file build action to Proguard configuration but still same error. any idea?

Sign In or Register to comment.