1

Good afternoon,

I decided to play around with Xamarin today, and I've been having a few issues getting Vector images to work. I've followed the instructions here and have the following in my layout:

<ImageView
    app:srcCompat="@drawable/fort"
    android:layout_height="wrap_content"
    android:id="@+id/imageView1" />

However, I get the following error at runtime:

Unhandled Exception: Java.Lang.IllegalStateException: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat. occurred

Throwing that error in Google, I get a few links, most notably, this StackOverflow post where most answers refer to the native Android SDK and include Gradle file modifications, but I'm not sure. I can't see any of the Gradle stuff from my VS project so I'm not sure I should edit them.

What should I do to fix this issue, is modifying the Gradle config the right answer?

James Parsons
  • 6,097
  • 12
  • 68
  • 108

1 Answers1

4

Add the Xamarin.Android.Support.Vector.Drawable nuget package to your Xamarin.Android project.

NOTE: The Xamarin.Android.Support.Vector.Drawable nuget package contains a .targets file which appends the argument --no-version-vectors to AndroidResgenExtraArgs build property value to ensure the parameter is passed to the aapt invocation.

Which is basically the equivalent of editting the Gradle file. Information found here: https://components.xamarin.com/gettingstarted/xamandroidsupportvectordrawable?version=23.2.1

Raimo
  • 1,494
  • 1
  • 10
  • 19
  • I've already added it, as well as switched my `Activity` class to `AppCompatActivity` – James Parsons Mar 05 '18 at 13:29
  • @James_Parsons I have updated my answer. Besides adding Xamarin.Android.Support.v7.AppCompat, you also have to add the Xamarin.Android.Support.Vector.Drawable nuget package to your Xamarin.Android project. – Raimo Mar 05 '18 at 16:59
  • @James_Parsons If this solved your problem, please accept the answer. If not, can you give us an update? – Raimo Mar 08 '18 at 13:45