Bug 5825 - Java.Lang.NoClassDefFoundError during runtime
Summary: Java.Lang.NoClassDefFoundError during runtime
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-06-22 12:44 UTC by Mark Bowman
Modified: 2012-09-18 05:58 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Contains two zip files. One for MfA solution and the other with the Java code. (149.72 KB, application/octet-stream)
2012-06-22 12:45 UTC, Mark Bowman

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mark Bowman 2012-06-22 12:44:29 UTC
I have a MfA project that has been referencing a .jar file wrapping the android licensing library.  This setup was working fine in MfA 4.0.6, but when I upgraded to 4.2.2 and 4.2.3, I now get an error packaging about a duplicate key in the dictionary.  I was able to resolve the packaging issue by using the new binding library project.  However, when I attempt to call a static method in my wrapper class I get the Java.Lang.NoClassDefFoundError.  Below is the stack trace within the log.  I have also included a sample project to produce the error.  Included in the attachment is both the MfA solution, as well as the Eclipse project code that wraps the Android licensing library.  The LicenseHelper.cs file calls the CheckLicense static method from the binding library's C# LicensingWrapper class.  This is where the error is thrown.



Log stack trace:
06-22 12:25:22.616 E/Test    (17300): Error checking license: Java.Lang.NoClassDefFoundError: Exception of type 'Java.Lang.NoClassDefFoundError' was thrown.
06-22 12:25:22.616 E/Test    (17300):   at Android.Runtime.JNIEnv.FindClass (System.String classname) [0x00000] in <filename unknown>:0 
06-22 12:25:22.616 E/Test    (17300):   at Android.Runtime.JNIEnv.FindClass (System.String className, System.IntPtr& cachedJniClassHandle) [0x00000] in <filename unknown>:0 
06-22 12:25:22.616 E/Test    (17300):   at Mobile.Timesheets.LicensingWrapper.get_class_ref () [0x00000] in <filename unknown>:0 
06-22 12:25:22.616 E/Test    (17300):   at Mobile.Timesheets.LicensingWrapper.CheckLicense (Android.App.Activity p0, System.String p1) [0x00000] in <filename unknown>:0 
06-22 12:25:22.616 E/Test    (17300):   at AndroidApplication1.LicenseHelper.CheckLicense (Android.App.Activity activity, System.EventHandler`1 licenseResultCallback) [0x00000] in <filename unknown>:0 
06-22 12:25:22.616 E/Test    (17300):   --- End of managed exception stack trace ---
06-22 12:25:22.616 E/Test    (17300): java.lang.NoClassDefFoundError: Mobile.Timesheets.LicensingWrapper
06-22 12:25:22.616 E/Test    (17300): 	at mono.android.view.View_OnClickListenerImplementor.n_onClick(Native Method)
06-22 12:25:22.616 E/Test    (17300): 	at mono.android.view.View_OnClickListenerImplementor.onClick(View_OnClickListenerImplementor.java:29)
06-22 12:25:22.616 E/Test    (17300): 	at android.view.View.performClick(View.java:2532)
06-22 12:25:22.616 E/Test    (17300): 	at android.view.View$PerformClick.run(View.java:9293)
06-22 12:25:22.616 E/Test    (17300): 	at android.os.Handler.handleCallback(Handler.java:587)
06-22 12:25:22.616 E/Test    (17300): 	at android.os.Handler.dispatchMessage(Handler.java:92)
06-22 12:25:22.616 E/Test    (17300): 	at android.os.Looper.loop(Looper.java:150)
06-22 12:25:22.616 E/Test    (17300): 	at android.app.ActivityThread.main(ActivityThread.java:4263)
06-22 12:25:22.616 E/Test    (17300): 	at java.lang.reflect.Method.invokeNative(Native Method)
06-22 12:25:22.616 E/Test    (17300): 	at java.lang.reflect.Method.invoke(Method.java:507)
06-22 12:25:22.616 E/Test    (17300): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-22 12:25:22.616 E/Test    (17300): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-22 12:25:22.616 E/Test    (17300): 	at dalvik.system.NativeStart.main(Native Method)
06-22 12:25:22.616 E/Test    (17300): Caused by: java.lang.ClassNotFoundException: Mobile.Timesheets.LicensingWrapper in loader dalvik.system.PathClassLoader[/data/app/Android.Test-2.apk]
06-22 12:25:22.616 E/Test    (17300): 	at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-22 12:25:22.616 E/Test    (17300): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-22 12:25:22.616 E/Test    (17300): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-22 12:25:22.616 E/Test    (17300): 	... 13 more
Comment 1 Mark Bowman 2012-06-22 12:45:54 UTC
Created attachment 2103 [details]
Contains two zip files.  One for MfA solution and the other with the Java code.
Comment 2 Mark Bowman 2012-06-29 09:15:55 UTC
Any update?  I won't be able to release the latest version of my app without this being fixed.  My only other alternative is to revert back to an earlier version of MfA.
Comment 3 Atsushi Eno 2012-09-07 12:03:33 UTC
I can't reproduce with the latest unpublished master. If this reproduces with 4.2.5 it is likely already fixed. Need to check with 4.2.5.
Comment 4 Atsushi Eno 2012-09-18 05:58:49 UTC
It does not reproduce on 4.2.5 anymore either. I can see similar UnsatisfiedLinkError  only when I ran it on non-Google emulator. If you still see the problem please reopen and we'll ask for the details. Thanks.