[英]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: 编辑 - 添加了包的外观:
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: 你的例子有:
But in my code i have: 但在我的代码中,我有:
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诊断程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.