繁体   English   中英

Xamarin Android 应用程序遇到在路径上找不到类...:DexPathList[[zip 文件...]...]

[英]Xamarin Android app encountering Didn't find class … on path: DexPathList[[zip file …]…]

当我尝试在 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

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

感谢对该问题的评论,我发现这是一个可以通过每次清理和重建来解决的错误。

我在 Xamarin Android 绑定项目中遇到了同样的问题,解决方法是将本机 .jar/.aar 库的构建操作设置为 EmbeddedJar。 默认值为 InputJar,这意味着生成的 apk 将没有本机库,除非您直接提供它。 https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/#build-actions

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM