简体   繁体   English

Xamarin Forms错误:Java.Lang.NoClassDefFoundError:android.support.graphics.drawable.VectorDrawableCompat

[英]Xamarin Forms error: Java.Lang.NoClassDefFoundError: android.support.graphics.drawable.VectorDrawableCompat

When starting debugging of my project on the Android emulator I receive this error: 在Android模拟器上开始调试我的项目时,我收到此错误:

Java.Lang.NoClassDefFoundError: android.support.graphics.drawable.VectorDrawableCompat Java.Lang.NoClassDefFoundError:android.support.graphics.drawable.VectorDrawableCompat

At this code: 在这段代码:

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
        //SQLitePCL.Batteries.Init();
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);

        string dbPath = FileAccessHelper.GetLocalFilePath("clocker.db3");

        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new Clocker.App(dbPath));
    }
}

The error occurs on this row: 此行发生错误:

base.OnCreate(bundle);

I have tried looking online at the other suggestions but the answers seem related to specific Xamarin studio files which are non-existant in my project (ig the gradle file). 我试过在线查看其他建议,但答案似乎与我的项目中不存在的特定Xamarin工作室文件有关(ig gradle文件)。

I have checked the contents of 'bundle' and it seems to be null at the time of the error but I'm unsure if this is causing the error. 我检查了'bundle'的内容,它在出错时似乎是null但我不确定这是否导致错误。

I'm using Xamarin forms PCL. 我正在使用Xamarin表格PCL。

This error may occurs with several class if the project path is too long, because it go through the limit of Operational System character length. 如果项目路径太长,则可能会在多个类中发生此错误,因为它会经历操作系统字符长度的限制。

Example of Long path: 长路径示例:

C:\\Users\\Username\\Documents\\Visual Studio xxxx\\Projects\\Project Name C:\\ Users \\ Username \\ Documents \\ Visual Studio xxxx \\ Projects \\ Project Name

Example of Good path: 好路径示例:

C:\\Projects\\ProjectName C:\\项目\\项目名

EDIT - Added how the packages should look: 编辑 - 添加了包的外观:

包Pic

The error Java.Lang.NoClassDefFoundError: means that you're missing a class. 错误Java.Lang.NoClassDefFoundError:意味着你错过了一个类。 It tells you which class you're missing as well: android.support.graphics.drawable.VectorDrawableCompat . 它告诉你你也缺少哪个类: android.support.graphics.drawable.VectorDrawableCompat I've not used Xamarin myself, but their documentation describes how to use Java classes in C# code. 我自己没有使用过Xamarin,但他们的文档描述了如何在C#代码中使用Java类 Once the package which includes the class android.support.graphics.drawable.VectorDrawableCompat (VectorDrawableCompat.java, which is in android.support.graphics.drawable I think?) is imported, your code should run. 一旦包含类android.support.graphics.drawable.VectorDrawableCompat (VectorDrawableCompat.java,在android.support.graphics.drawable中,我认为?)的包被导入,你的代码应该运行。

I am not sure if this will help you but look at the way the MainActivity is declared. 我不确定这是否会对你有所帮助,但我们会看看MainActivity的声明方式。

Your example has: 你的例子有:

  • public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity 公共类MainActivity:global :: Xamarin.Forms.Platform.Android.FormsAppCompatActivity

But in my code i have: 但在我的代码中,我有:

  • public class MainActivity : Xamarin.Forms.Platform.Android.FormsApplicationActivity 公共类MainActivity:Xamarin.Forms.Platform.Android.FormsApplicationActivity

See if that makes a difference to the startup. 看看这对创业公司是否有所作为。 If you have to use FormsAppCompatActivity then see if changing the Api level to the highest supported level makes a difference. 如果必须使用FormsAppCompatActivity,那么请查看将Api级别更改为支持的最高级别是否有所不同。

Do you have any logs from the Output window, Show Xamarin Diagnostics. 您是否在“输出”窗口中显示任何日志,显示Xamarin诊断程序。

I had a similar error. 我有类似的错误。 I resolved it to install the latest version of JDK and select the new folder in Visual Studio. 我解决了它安装最新版本的JDK并在Visual Studio中选择新文件夹。

Visual Studio 2015上的Xamarin设置

暂无
暂无

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

相关问题 java.lang.NoClassDefFoundError Android Studio Unity - java.lang.NoClassDefFoundError Android Studio Unity Xamarin.Android 绑定 Java.Lang.NoClassDefFoundError: '解析失败: Landroidx/viewbinding/ViewBinding;' - Xamarin.Android binding Java.Lang.NoClassDefFoundError: 'Failed resolution of: Landroidx/viewbinding/ViewBinding;' 如何修复 Xamarin.Android 绑定项目 (.aar) 中的“Java.Lang.NoClassDefFoundError” - How to fix "Java.Lang.NoClassDefFoundError" in a Xamarin.Android Binding Project (.aar) Xamarin Android 原生绑定 Java.Lang.NoClassDefFoundError: 'Failed resolution of: [Lkotlin/reflect/KProperty - Xamarin Android Native bindings Java.Lang.NoClassDefFoundError: 'Failed resolution of: [Lkotlin/reflect/KProperty;' Java.Lang.NoClassDefFoundError:超时超过了获取异常详细信息Xamarin Android - Java.Lang.NoClassDefFoundError: Timeout exceeded getting exception details Xamarin Android Java.Lang.NoClassDefFoundError android.arch.core.internal.FastSafeIterableMap - Java.Lang.NoClassDefFoundError android.arch.core.internal.FastSafeIterableMap 扩展DataMediaSource时发生Java.Lang.NoClassDefFoundError - Java.Lang.NoClassDefFoundError on extending DataMediaSource Mixpanel绑定上的java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError on Mixpanel bindings Xamarin Forms Android 出 Z93F725A07423FE1C889F448B33Demory1F46 异常 - Xamarin Forms Android out java.lang.OutOfMemoryError exception Drawable 未出现在 Button Xamarin Forms Android 上 - Drawable not appearing on Button Xamarin Forms Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM