Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

NoClassDefFoundError when instantiating JAR library native class in Xamarin Android Bind project

$
0
0

Hello,

I have created a JAR file that I added to a binding project and referenced in a library which is referenced in the main Xamarin Android application. It seems that classes are properly generated and I can use them (at least in theory) in my application.

When trying to instantiate the class AndroidManager I get the following NoClassDefFoundError exception and the application crashes.

Java.Lang.NoClassDefFoundError: com/androidtest/bind/xamarin/AndroidManager
  at Android.Runtime.JNIEnv.FindClass (string) [0x00087] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.1-branch/d23a19bf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:378
  at Android.Runtime.JNIEnv.FindClass (string,intptr&) [0x00014] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.1-branch/d23a19bf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:391
  at Com.androidtest.Bind.Xamarin.AndroidManager.get_class_ref () [0x00001] in c:\Users\George\Documents\Projects\AndroidTest\AndroidTest.Platforms\AndroidTest.Xamarin.Bind.Android\obj\Debug\generated\src\Com.androidtest.Bind.Xamarin.AndroidManager.cs:14
  at Com.androidtest.Bind.Xamarin.AndroidManager..ctor () [0x00094] in c:\Users\George\Documents\Projects\AndroidTest\AndroidTest.Platforms\AndroidTest.Xamarin.Bind.Android\obj\Debug\generated\src\Com.androidtest.Bind.Xamarin.AndroidManager.cs:45
  at AndroidTest.AndroidTestHandler.InitAndStartSession (AndroidTest.Model.IExceptionManager,Android.Content.Context,string) [0x00044] in c:\Users\George\Documents\Projects\AndroidTest\AndroidTest.Platforms\AndroidTest.Xamarin.Android\AndroidTestHandler.cs:101
  at AndroidTest.Android.Activity1.OnCreate (Android.OS.Bundle) [0x00010] in c:\Users\George\Documents\Projects\AndroidTest\AndroidTest.Platforms\AndroidTest.Android\Activity1.cs:28
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.10.1-branch/d23a19bf/source/monodroid/src/Mono.Android/platforms/android-17/src/generated/Android.App.Activity.cs:2119
  at at (wrapper dynamic-method) object.0a7f761a-6825-4eb3-94cb-73fd30d0cfe0 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
  at 
  at --- End of managed exception stack trace ---
  at java.lang.NoClassDefFoundError: com/androidtest/bind/xamarin/AndroidManager
  at    at androidtest.android.Activity1.n_onCreate(Native Method)
  at    at androidtest.android.Activity1.onCreate(Activity1.java:28)
  at    at android.app.Activity.performCreate(Activity.java:5231)
  at    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  at    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
  at    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
  at    at android.app.ActivityThread.access$800(ActivityThread.java:135)
  at    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  at    at android.os.Handler.dispatchMessage(Handler.java:102)
  at    at android.os.Looper.loop(Looper.java:136)
  at    at android.app.ActivityThread.main(ActivityThread.java:5017)
  at    at java.lang.reflect.Method.invokeNative(Native Method)
  at    at java.lang.reflect.Method.invoke(Method.java:515)
  at    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  at    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  at    at dalvik.system.NativeStart.main(Native Method)
  at Caused by: java.lang.ClassNotFoundException: Didn't find class "com.androidtest.bind.xamarin.AndroidManager" on path: DexPathList[[zip file "/data/app/AndroidTest.Xamarin.AndroidTestApp-1.apk"],nativeLibraryDirectories=[/data/app-lib/AndroidTest.Xamarin.AndroidTestApp-1, /vendor/lib, /system/lib]]
  at    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  at    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
  at    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
  at    ... 16 more
  at

To tell the truth, I'm not quite sure at this point if I have something wrong when building the JAR or I miss something.

I have successfully bind an iOS static library previously.

Any thoughts?

Regards.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>