I downloaded an icon from google Material.io. while trying to build my project after integrating it, I ran into the error that says: Can't process attribute android:fillColor="@android:color/white"
Here is a screenshot:
I downloaded an icon from google Material.io. while trying to build my project after integrating it, I ran into the error that says: Can't process attribute android:fillColor="@android:color/white"
Here is a screenshot:
In the app build.gradle add the following line within the android
section:
defaultConfig{
vectorDrawables.useSupportLibrary = true
}
Check This For Further Detail :Vector drawables overview
Open the drawable you downloaded and replace android:fillColor="@android:color/white"
with android:fillColor="#ffffff"
. In vector drawables the fillColor
attribute must be set explicitly and not reference other resources
There are two ways to fix this.
One quick option is to go to the problematic XML file and change android:fillColor="@android:color/white"
to android:fillColor="#FFFFFF"
. The error would disappear immediately. However, this problem would still recur if you have any other file with a similar line in the future.
Here's permanent solution:
Go to your build.gradle file and add this:
defaultConfig{
vectorDrawables.useSupportLibrary = true
}
Sync and the error would disappear immediately.
AS 3.3.2 / gradle-4.10.1
I had the same compiler problem:
Error: java.lang.RuntimeException: java.lang.RuntimeException: Error while processing .../main/res/drawable/ic_white_set.xml : Can't process attribute android:fillColor="@color/selector_tab_color": references to other resources are not supported by build-time PNG generation.
I opened the incriminated file and got the following Lint warning:
Resource references will not work correctly in images generated for this vector icon for API < 21; check generated icon to make sure it looks acceptable.
Inspection info:Vector icons require API 21 or API 24 depending on used features, but when minSdkVersion is less than 21 or 24 and Android Gradle plugin 1.4 or higher is used, a vector drawable placed in the drawable folder is automatically moved to drawable-anydpi-v21 or drawable-anydpi-v24 and bitmap images are generated for different screen resolutions for backwards compatibility. However, there are some limitations to this raster image generation, and this lint check flags elements and attributes that are not fully supported. You should manually check whether the generated output is acceptable for those older devices. Issue id: VectorRaster
Then I checked my build.gradle
files and, sure enough, they all had minSdkVersion
to 16.
So, as an alternative to the @Bhavesh Moradiya solution, I set minSdkVersion
to 21 and the problem was solved.
The drawback is that you lose support for devices with SDK < 16 though.