43
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.

How can we solve this?

Android Geek
  • 8,956
  • 2
  • 21
  • 35
Nikhilesh Patve
  • 1,760
  • 3
  • 13
  • 31
  • Try cleaning the project and rebuildit – Abdul Waheed Oct 26 '17 at 06:15
  • Related thread for later part of the error text which is present in the logs - [References to other resources are not supported by build-time PNG generation](https://stackoverflow.com/q/46978566/465053) – RBT Aug 30 '18 at 05:10

3 Answers3

105

You can add the following line inside your default config of your app build.gradle:

defaultConfig{
   vectorDrawables.useSupportLibrary = true
}

Edit: you also need to add this dependency if you didn't already

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

Update:

Since Gradle 3.4 the compile configuration is deprecated and should be replaced by implementation:

dependencies {
    implementation 'com.android.support:appcompat-v7:27.1.1'
}
Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
rotemitz
  • 1,088
  • 1
  • 8
  • 10
12

The problem is because the new gradle cannot refer to color library, which you use to get the @color/green value.

The solution is same as rotemitz said Just add this line to your defaultConfig of build.gradle (Module : app)

vectorDrawables.useSupportLibrary = true

AND to dependencies of the same build.gradle

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

Note : You may change the appcompat version, refer to your compile SDK version

Andrew
  • 123
  • 4
7

You just need to add the following line inside your default config of your app build.gradle:

defaultConfig{
       vectorDrawables.useSupportLibrary = true
    }
Android Geek
  • 8,956
  • 2
  • 21
  • 35