找不到类别 - Xamarin Android

时间:2017-06-05 18:09:02

标签: java xamarin xamarin.android classnotfoundexception

构建我的Xamarin.Android项目时出现此错误。

06-05 12:42:15.322 I/MonoDroid(30682): UNHANDLED EXCEPTION:
06-05 12:42:15.380 I/MonoDroid(30682): Java.Lang.ClassNotFoundException: Didn't find class "md565316a0900a9b0d8bca349e28cad6b91.AndroidVPNConnection_LaunchVPNServiceConnection" on path: DexPathList[[zip file "/data/app/com.redcheetah-1/base.apk"],nativeLibraryDirectories=[/data/app/com.redcheetah-1/lib/arm, /vendor/lib, /system/lib]]
06-05 12:42:15.380 I/MonoDroid(30682):   at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00114] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
06-05 12:42:15.380 I/MonoDroid(30682):   at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
06-05 12:42:15.380 I/MonoDroid(30682):   at Java.Interop.JniPeerMembers+JniInstanceMethods..ctor (System.Type declaringType) [0x00064] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
06-05 12:42:15.380 I/MonoDroid(30682):   at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructorsForType (System.Type declaringType) [0x0002c] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
06-05 12:42:15.380 I/MonoDroid(30682):   at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x00032] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
06-05 12:42:15.380 I/MonoDroid(30682):   at Java.Lang.Object..ctor () [0x0001f] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/obj/Release/android-23/mcw/Java.Lang.Object.cs:30 
06-05 12:42:15.380 I/MonoDroid(30682):   at SwiftAndroidLib.AndroidVPNConnection+LaunchVPNServiceConnection..ctor (SwiftAndroidLib.AndroidVPNConnection outerInstance) [0x00000] in C:\WorkSpace\RC\ClientApp\SwiftLib\SwiftAndroidLib\AndroidVPNConnectionJavaBindingLib.cs:349 
06-05 12:42:15.380 I/MonoDroid(30682):   at SwiftAndroidLib.AndroidVPNConnection..ctor () [0x00034] in C:\WorkSpace\RC\ClientApp\SwiftLib\SwiftAndroidLib\AndroidVPNConnectionJavaBindingLib.cs:39 
06-05 12:42:15.380 I/MonoDroid(30682):   at SwiftCommonLib.SwiftBaseApp.RegisterPlatformSpecificServices () [0x0001e] in C:\WorkSpace\RC\ClientApp\SwiftLib\SwiftAndroidLib\SwiftAndroidApp.cs:81 
06-05 12:42:15.380 I/MonoDroid(30682):   at SwiftCommonLib.SwiftBaseApp+<RegisterPlatformServices>d__15.MoveNext () [0x0007f] in C:\WorkSpace\RC\ClientApp\SwiftLib\SwiftCommonLib\SwiftBaseApp.cs:41 
06-05 12:42:15.380 I/MonoDroid(30682): --- End of stack trace from previous location where exception was thrown ---
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113 
06-05 12:42:15.380 I/MonoDroid(30682):   at RedCheetah.RedCheetahApp+<RegisterPlatformServices>d__2.MoveNext () [0x00020] in C:\WorkSpace\RC\ClientApp\RedCheetah\RedCheetah.XFormsApp\RedCheetahApp.cs:39 
06-05 12:42:15.380 I/MonoDroid(30682): --- End of stack trace from previous location where exception was thrown ---
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113 
06-05 12:42:15.380 I/MonoDroid(30682):   at SwiftCommonLib.SwiftBaseApp+<Init>d__14.MoveNext () [0x0002b] in C:\WorkSpace\RC\ClientApp\SwiftLib\SwiftCommonLib\SwiftBaseApp.cs:20 
06-05 12:42:15.380 I/MonoDroid(30682): --- End of stack trace from previous location where exception was thrown ---
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
06-05 12:42:15.380 I/MonoDroid(30682):   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 
06-05 12:42:15.380 I/MonoDroid(30682):   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:35 
06-05 12:42:15.381 I/MonoDroid(30682):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
06-05 12:42:15.381 I/MonoDroid(30682):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/obj/Release/android-23/mcw/Java.Lang.IRunnable.cs:81 
06-05 12:42:15.381 I/MonoDroid(30682):   at (wrapper dynamic-method) System.Object:1b051e2f-3dbb-406a-ba95-3384e34e8ded (intptr,intptr)
06-05 12:42:15.381 I/MonoDroid(30682):   --- End of managed Java.Lang.ClassNotFoundException stack trace ---
06-05 12:42:15.381 I/MonoDroid(30682): java.lang.ClassNotFoundException: Didn't find class "md565316a0900a9b0d8bca349e28cad6b91.AndroidVPNConnection_LaunchVPNServiceConnection" on path: DexPathList[[zip file "/data/app/com.redcheetah-1/base.apk"],nativeLibraryDirectories=[/data/app/com.redcheetah-1/lib/arm, /vendor/lib, /system/lib]]
06-05 12:42:15.381 I/MonoDroid(30682):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
06-05 12:42:15.381 I/MonoDroid(30682):  at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-05 12:42:15.381 I/MonoDroid(30682):  at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
06-05 12:42:15.381 I/MonoDroid(30682):  at md53843fcbd823548032cdc16788941cea6.MainActivity.n_onCreate(Native Method)
06-05 12:42:15.381 I/MonoDroid(30682):  at md53843fcbd823548032cdc16788941cea6.MainActivity.onCreate(MainActivity.java:32)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.Activity.performCreate(Activity.java:6092)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2467)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2594)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.ActivityThread.access$800(ActivityThread.java:177)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1469)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.os.Handler.dispatchMessage(Handler.java:111)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.os.Looper.loop(Looper.java:194)
06-05 12:42:15.381 I/MonoDroid(30682):  at android.app.ActivityThread.main(ActivityThread.java:5627)
06-05 12:42:15.381 I/MonoDroid(30682):  at java.lang.reflect.Method.invoke(Native Method)
06-05 12:42:15.381 I/MonoDroid(30682):  at java.lang.reflect.Method.invoke(Method.java:372)
06-05 12:42:15.381 I/MonoDroid(30682):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
06-05 12:42:15.381 I/MonoDroid(30682):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
06-05 12:42:15.381 I/MonoDroid(30682):  Suppressed: java.lang.ClassNotFoundException: md565316a0900a9b0d8bca349e28cad6b91.AndroidVPNConnection_LaunchVPNServiceConnection
06-05 12:42:15.381 I/MonoDroid(30682):      at java.lang.Class.classForName(Native Method)
06-05 12:42:15.381 I/MonoDroid(30682):      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
06-05 12:42:15.381 I/MonoDroid(30682):      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
06-05 12:42:15.381 I/MonoDroid(30682):      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
06-05 12:42:15.381 I/MonoDroid(30682):      ... 16 more
06-05 12:42:15.381 I/MonoDroid(30682):  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
06-05 12:42:15.394 D/Mono    (30682): Assembly Ref addref HockeySDK.AndroidBindings[0xb46eba60] -> System[0x9c9daee0]: 10

我尝试了以下事项:

  • 重新安装Xamarin
  • 清理并重建解决方案(构建成功)
  • 我还在MSBuild中启用了诊断输出。

请问,如何解决此错误?

1 个答案:

答案 0 :(得分:0)

问题已修复,我需要在我的CSharp类中继承Java.Lang.Oject,即在我的错误消息中被引用的类。我需要这样做,因为我的类也继承了一些基于Java的Lib。