【问题标题】:Updated Android Studio to 3.0 and getting this issue将 Android Studio 更新到 3.0 并遇到此问题
【发布时间】:2017-10-26 06:12:56
【问题描述】:
Error:Execution failed for task ':App:mergeDebugResources'.
    > There were multiple failures while executing work items
       > A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkAction
          > Error while processing /media/nikhilesh/App/src/main/res/drawable/ic_add_black_24dp.xml : Can't process attribute android:fillColor="@color/green": references to other resources are not supported by build-time PNG generation. See http://developer.android.com/tools/help/vector-asset-studio.html for details.

我们如何解决这个问题?

【问题讨论】:

标签: android android-studio


【解决方案1】:

您可以在应用 build.gradle 的默认配置中添加以下行:

defaultConfig{
   vectorDrawables.useSupportLibrary = true
}

编辑:如果你还没有添加这个依赖项,你还需要添加

dependencies {
    compile 'com.android.support:appcompat-v7:27.1.1'
}

更新:

自 Gradle 3.4 起,compile 配置为 deprecated and should be replaced by implementation

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
}

【讨论】:

    【解决方案2】:

    问题是因为新的 gradle 不能引用颜色库,你用它来获取 @color/green 值。

    解决方法同rotemitz说的 只需将此行添加到 build.gradle (Module : app) 的 defaultConfig 中

    vectorDrawables.useSupportLibrary = true
    

    AND 到同一个 build.gradle 的依赖项

    compile 'com.android.support:appcompat-v7:23.1.0'
    

    注意:您可以更改 appcompat 版本,请参考您编译的 SDK 版本

    【讨论】:

      【解决方案3】:

      您只需在应用的默认配置中添加以下行 build.gradle:

      defaultConfig{
             vectorDrawables.useSupportLibrary = true
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-28
        • 1970-01-01
        • 2017-10-16
        • 1970-01-01
        相关资源
        最近更新 更多