c#-Xamarin Android应用程序在路径:DexPathList [[zip…]…]上找不到类…

当我尝试在Xamrin Android应用中执行以下代码行时遇到错误:

EntityEditor ee = new EntityEditor();

EntityEditor类是一个DialogFragment,其代码如下所示:

namespace Storyvoque
{
   public class EntityEditor : DialogFragment
   {
      EditText entityId;
      EditText entityType;
      EditText entityName;
      EditText entityDescription;
      EditText containerEntityId;
      AutoCompleteTextView containerEntityName;
      EditText targetEntityId;
      AutoCompleteTextView targetEntityName;
      EditText destinationEntityId;
      AutoCompleteTextView destinationEntityName;
      EditText entityOwner;
      EditText entityDate;
      CheckBox syncPending;

      public StoryEntity editData;

      public override void OnCreate(Bundle savedInstanceState)
      {
         base.OnCreate(savedInstanceState);

         // Create your fragment here
      }

      public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
         return inflater.Inflate(Resource.Layout.EntityEditor, container, false);
      }

      public override void OnViewCreated(View view, Bundle savedInstanceState)
      {
         entityId = (EditText)View.FindViewById(Resource.Id.entityId);
         entityType = (EditText)View.FindViewById(Resource.Id.entityType);
         entityName = (EditText)View.FindViewById(Resource.Id.entityName);
         entityDescription = (EditText)View.FindViewById(Resource.Id.entityDescription);
         containerEntityId = (EditText)View.FindViewById(Resource.Id.containerEntityId);
         containerEntityName = (AutoCompleteTextView)View.FindViewById(Resource.Id.containerEntityName);
         targetEntityId = (EditText)View.FindViewById(Resource.Id.targetEntityId);
         targetEntityName = (AutoCompleteTextView)View.FindViewById(Resource.Id.targetEntityName);
         destinationEntityId = (EditText)View.FindViewById(Resource.Id.destinationEntityId);
         destinationEntityName = (AutoCompleteTextView)View.FindViewById(Resource.Id.destinationEntityName);
         entityOwner = (EditText)View.FindViewById(Resource.Id.entityOwner);
         entityDate = (EditText)View.FindViewById(Resource.Id.entityDate);
         syncPending = (CheckBox)View.FindViewById(Resource.Id.syncPending);

         base.OnViewCreated(view, savedInstanceState);
      }

      public void LoadData(StoryData source, UserData users, StoryEntity data)
      {
         entityId.Text = data.EntityId.ToString();
         entityType.Text = data.EntityType.ToString();
         entityName.Text = data.Name;
         entityDescription.Text = data.Text;
         containerEntityId.Text = data.Container.ToString();
         containerEntityName.Text = source.GetWrapper(data.Container)?.Name ?? string.Empty;
         targetEntityId.Text = data.Target.ToString();
         targetEntityName.Text = source.GetWrapper(data.Target)?.Name ?? string.Empty;
         destinationEntityId.Text = data.Destination.ToString();
         destinationEntityName.Text = source.GetWrapper(data.Destination)?.Name ?? string.Empty;
         entityOwner.Text = users[data.UserNum]?.DisplayName ?? data.UserNum.ToString();
         entityDate.Text = data.Date.ToLocalTime().ToString("G");
         syncPending.Checked = data.SyncRequired;
      }

      public void StoreData(StoryEntity data)
      {
         data.EntityId = Int32.Parse(entityId.Text);
         data.Name = entityName.Text;
         data.Text = entityDescription.Text;
         data.Container = Int32.Parse(containerEntityId.Text);
         data.Target = Int32.Parse(targetEntityId.Text);
         data.Destination = Int32.Parse(destinationEntityId.Text);
      }

      public override void OnDismiss(IDialogInterface dialog)
      {
         StoreData(editData);
         base.OnDismiss(dialog);
      }
   }
}

我假设我们不需要查看AXML文件,因为它不会在错误发生之前到达OnCreatedView函数.错误的调用堆栈如下所示:

Java.Lang.ClassNotFoundException: Didn't find class "md59096a9123c571e4f030e303e8372967e.EntityEditor" on path: DexPathList[[zip file "/data/app/com.enigmadream.storyvoque-1/base.apk"],nativeLibraryDirectories=[/data/app/com.enigmadream.storyvoque-1/lib/x86, /data/app/com.enigmadream.storyvoque-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
  at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00114] in <54816278eed9488eb28d3597fecd78f8>:0 
  at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <54816278eed9488eb28d3597fecd78f8>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods..ctor (System.Type declaringType) [0x00064] in <54816278eed9488eb28d3597fecd78f8>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.GetConstructorsForType (System.Type declaringType) [0x0002c] in <54816278eed9488eb28d3597fecd78f8>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x00032] in <54816278eed9488eb28d3597fecd78f8>:0 
  at Android.App.DialogFragment..ctor () [0x00034] in <28e323a707a2414f8b493f6d4bb27c8d>:0 
  at Storyvoque.EntityEditor..ctor () <0x97e236a0 + 0x0002b> in <c813259d00bd4c8dafdb14124c1c8a19>:0 
  at Storyvoque.CommandProcessor.ProcessCommand (Storyvoque.Parser.Command command, Storyvoque.UserData users, Storyvoque.StoryData storyData, System.Boolean activePlayer) [0x00091] in C:\Users\bluem\Documents\Visual Studio 2017\Projects\Storyvoque\Storyvoque\CommandProcessor.cs:29 
  at Storyvoque.MainActivity.SendCommand (Android.Views.View view) [0x000fb] in C:\Users\bluem\Documents\Visual Studio 2017\Projects\Storyvoque\Storyvoque\MainActivity.cs:146 
  --- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: Didn't find class "md59096a9123c571e4f030e303e8372967e.EntityEditor" on path: DexPathList[[zip file "/data/app/com.enigmadream.storyvoque-1/base.apk"],nativeLibraryDirectories=[/data/app/com.enigmadream.storyvoque-1/lib/x86, /data/app/com.enigmadream.storyvoque-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    at md59096a9123c571e4f030e303e8372967e.MainActivity.n_SendCommand(Native Method)
    at md59096a9123c571e4f030e303e8372967e.MainActivity.SendCommand(MainActivity.java:42)
    at java.lang.reflect.Method.invoke(Native Method)
    at android.view.View$DeclaredOnClickListener.onClick(View.java:4447)
    at android.view.View.performClick(View.java:5198)
    at android.view.View$PerformClick.run(View.java:21147)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Suppressed: java.lang.ClassNotFoundException: md59096a9123c571e4f030e303e8372967e.EntityEditor
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 14 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

如何缩小或解决这个问题?

解决方法:

感谢对该问题的评论,我found这是一个可以每次清洁和重建即可解决的错误.

上一篇:[转]CDN(内容分发网络)技术原理


下一篇:c#-将MasterDetailPage的背景设置为透明