Forum Xamarin.Android not inside apk

KinkKink Member ✭✭
edited February 2019 in Xamarin.Android


I recently made a xamarin binding of a third-party lib which I then built as a nuget.
The third-party lib has a dependancy on the google firebase messaging lib.
I seem to have built my nuget correctly since when I look at the nuget description/dependancies,
it lists :
Xamarin.Firebase.Messaging (>= 70.1710.0-preview2).

Then I use the command line msbuild xxxxx.csproj /p:Configuration:Release /p:Platform="AnyCPU" /t:SignAndroidPackage to build my app's .apk
When I run the app, it crashes with :

02-21 13:21:13.963: I/art(9201): Rejecting re-init on previously-failed class java.lang.Class<xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/messaging/FirebaseMessagingService;

Sometimes, I build my apk... same command, same everything and it works fine!
I managed to get a working apk and a not working one and try to find the differences between the two and found something weird but I have no idea if it means anything or not. Basically, in the .apk, there's a folder "assemblies" and I can see in both case (working and not working apk) that Xamarin.Firebase.Messaging.dll is there.

BUT, there's one file that is there in the working .apk but NOT there in the not working .apk... that file is in the root of the .apk and is : Inside, there's only the following :


So I'm at a loss here... is my "not-working" .apk not working because it's missing this file? And I can't figure out why sometimes that file is there and sometimes it's not.

Please help! :)



  • MicialMicial USMember ✭✭

    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/messaging/FirebaseMessagingService;

    The most likely reason for this error is that a mandatory Java library needs to be added to the application project (.csproj). .JAR files are not automatically resolved. A Java library binding is not always generated against a user assembly that does not exist in the target device or emulator (such as Google Maps maps.jar). This is not the case for Android Library project support, as the library .JAR is embedded in the library dll.

  • KinkKink Member ✭✭

    I fixed the problem by manually installing the firebase-messaging nuget in my project instead of letting the automatic dependency mechanism include the firebase-messaging nuget itself.

    By that I mean that my third-party lib nuget says that it depends on :
    Xamarin.Firebase.Messaging (>= 70.1710.0-preview2)
    but it doesn't seem to always include it automatically... but when I manually install the firebase-messaging nuget in my project, it works all the time.

    I'm guessing I have a problem with my home-made nuget but right now this seems to fix the problem.

Sign In or Register to comment.