I'm trying to bind the libuvccamera java library to access UVC camera in Android device developing in Xamarin.Android, and during the binding of the libuvccamera.aar and the usbCameraCommon.aar file I've a lot of trouble. Once of this is the java.lang.ClassNotFoundException that was called when a called the USBMonitor costructor of the java class:
USBMonitor usb_monitor;
try
{
usb_monitor = new USBMonitor(this, this);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
I've imported the .arr libraries as described here
but when I create the distribution and run the application to my Android device I get the exception call as below:
Failed resolution of: Lcom/serenegiant/utils/HandlerThreadHandler;
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in <94b04e1756104d1fa1d144932ae2720c>:0
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (System.IntPtr jobject, System.IntPtr jclass, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x00000] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.g.cs:444
at Android.Runtime.JNIEnv.FinishCreateInstance (System.IntPtr instance, System.IntPtr jclass, System.IntPtr constructorId, Android.Runtime.JValue* constructorParameters) [0x00008] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:362
at Com.Serenegiant.Usb.USBMonitor..ctor (Android.Content.Context context, Com.Serenegiant.Usb.USBMonitor+IOnDeviceConnectListener listener) [0x000df] in C:\dev\code\curr\LETTURA_DATA_MATRIX_LUXOTTICA\DEMO\TEST_UVC_CAMERA_LIB\TEST_3\LIBUVC\obj\Debug\generated\src\Com.Serenegiant.Usb.USBMonitor.cs:1076
at TEST_3.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0001e] in C:\dev\code\curr\LETTURA_DATA_MATRIX_LUXOTTICA\DEMO\TEST_UVC_CAMERA_LIB\TEST_3\TEST_3\MainActivity.cs:28
--- End of managed Java.Lang.NoClassDefFoundError stack trace ---
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/serenegiant/utils/HandlerThreadHandler;
at com.serenegiant.usb.USBMonitor.<init>(USBMonitor.java:122)
at crc645ed0f3853a61fd03.MainActivity.n_onCreate(Native Method)
at crc645ed0f3853a61fd03.MainActivity.onCreate(MainActivity.java:44)
at android.app.Activity.performCreate(Activity.java:7957)
at android.app.Activity.performCreate(Activity.java:7946)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3598)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3775)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2261)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.serenegiant.utils.HandlerThreadHandler" on path: DexPathList[[zip file "/data/app/com.companyname.test_3-RASdU4LTR0mcU0jXj9KO8Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.test_3-RASdU4LTR0mcU0jXj9KO8Q==/lib/arm, /data/app/com.companyname.test_3-RASdU4LTR0mcU0jXj9KO8Q==/base.apk!/lib/armeabi-v7a, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 18 more
Some suggestions how to solve this problem?
Thanks!
I've solved the issue. I've to implement in the .arr library the HandlerThreadHandler class, so the costructor of the USBMonitor class can found it.