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

When I start debugging my project on an Android emulator, I get this error:

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

In 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 in this line is:

 base.OnCreate(bundle); 

I tried looking online for other suggestions, but the answers seem to be related to specific Xamarin studio files that do not exist in my project (e.g. gradle file).

I checked the contents of the "bundle" and it seems to be null during the error, but I'm not sure if this caused an error.

I am using Xamarin forms PCL.

+6
source share
4 answers

This error can occur with several classes if the path to the project is too long, because it passes the character length limit of the operating system.

An example of a long journey:

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

An example of a good way:

C: \ Projects \ ProjectName

EDIT - added what packages should look like:

Pic Packs

+1
source

Java.Lang.NoClassDefFoundError: error means that you are missing a class. It tells you which class you are missing too: android.support.graphics.drawable.VectorDrawableCompat . I myself have not used Xamarin, but their documentation describes how to use Java classes in C # code. Once the package that includes the android.support.graphics.drawable.VectorDrawableCompat class (VectorDrawableCompat.java, which is in android.support.graphics.drawable , I think?) Is imported, your code should work.

0
source

I'm not sure this will help you, but look at how MainActivity is declared.

In your example:

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

But in my code, I have:

  • public class MainActivity: Xamarin.Forms.Platform.Android.FormsApplicationActivity

See if it matters to run. If you need to use FormsAppCompatActivity, then see if changing the Api level changes to the highest level of support.

Do you have logs from the Output window, Show Xamarin Diagnostics.

0
source

I had a similar error. I decided to install the latest version of JDK and select a new folder in Visual Studio.

Configuring Xamarin on Visual Studio 2015

0
source

Source: https://habr.com/ru/post/1011720/


All Articles