【问题标题】:Xamarin Android: This app has been built with an incorrect configurationXamarin Android:此应用程序的配置不正确
【发布时间】:2018-03-04 22:11:01
【问题描述】:

下午好,

我今天决定使用 Xamarin,但在使用 Vector 图像时遇到了一些问题。我遵循了here 的说明,并在我的布局中包含以下内容:

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

但是,我在运行时收到以下错误:

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

在 Google 中抛出该错误,我得到了一些链接,最值得注意的是,this StackOverflow post,其中大多数答案是指本机 Android SDK 并包括 Gradle 文件修改,但我不确定。我在我的 VS 项目中看不到任何 Gradle 内容,所以我不确定是否应该编辑它们。

我应该怎么做才能解决这个问题,修改 Gradle 配置是正确的答案吗?

【问题讨论】:

  • 假设您已将活动继承更改为AppCompatActivity 并添加Android.Support.v7.AppCompat
  • @SushiHangover 我有
  • 如果对你有帮助请采纳我的回答

标签: xamarin xamarin.android android-support-library android-vectordrawable


【解决方案1】:

Xamarin.Android.Support.Vector.Drawable nuget package 添加到您的 Xamarin.Android 项目。

注意:Xamarin.Android.Support.Vector.Drawable nuget 包包含一个 .targets 文件,该文件将参数 --no-version-vectors 附加到 AndroidResgenExtraArgs 构建属性值,以确保将参数传递给 aapt 调用。

这基本上相当于编辑 Gradle 文件。在此处找到信息:https://components.xamarin.com/gettingstarted/xamandroidsupportvectordrawable?version=23.2.1

【讨论】:

  • 我已经添加了它,并将我的 Activity 类切换到 AppCompatActivity
  • @James_Parsons 我已经更新了我的答案。除了添加 Xamarin.Android.Support.v7.AppCompat,您还必须将 Xamarin.Android.Support.Vector.Drawable nuget 包添加到您的 Xamarin.Android 项目中。
  • @James_Parsons 如果这解决了您的问题,请接受答案。如果没有,你能给我们一个更新吗?
猜你喜欢
  • 1970-01-01
  • 2010-10-01
  • 2011-09-16
  • 2010-09-11
  • 2012-05-04
  • 1970-01-01
  • 1970-01-01
  • 2010-09-24
  • 2017-08-07
相关资源
最近更新 更多