无法处理属性android:fillColor =“ @ android:color / white”

时间:2018-07-13 12:49:58

标签: android android-drawable

我从Google Material.io下载了一个图标。整合后尝试构建我的项目时,我遇到了一个错误:Can't process attribute android:fillColor="@android:color/white"

这是屏幕截图: Can't process attribute android:fillColor="@android:color/white"

5 个答案:

答案 0 :(得分:5)

打开您下载的绘图,并将android:fillColor="@android:color/white"替换为android:fillColor="#ffffff"。在矢量可绘制对象中,必须显式设置fillColor属性,并且不能引用其他资源

答案 1 :(得分:5)

build.gradle 中添加以下行:

d = 20.09

检查此内容以获取更多详细信息:Vector drawables overview

答案 2 :(得分:1)

有两种解决方法。

一个快速的选择是转到有问题的XML文件,并将android:fillColor="@android:color/white"更改为android:fillColor="#FFFFFF"。该错误将立即消失。但是,如果将来有其他任何类似的行,此问题仍然会再次发生。

这是永久解决方案:

转到您的build.gradle文件并添加以下内容:

defaultConfig{
    vectorDrawables.useSupportLibrary = true
}

同步,错误将立即消失。

答案 3 :(得分:0)

您应该使用 AppCompatTheme 来访问?attr / colorControlNormal

答案 4 :(得分:0)

AS 3.3.2 / gradle-4.10.1

我遇到了相同的编译器问题:

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.

我打开了该文件,并收到以下Lint警告:

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

然后,我检查了我的build.gradle个文件,当然,它们都具有minSdkVersion至16个。

因此,作为@Bhavesh Moradiya解决方案的替代方案,我将minSdkVersion设置为21,问题得到解决。

缺点是您会失去对SDK <16的设备的支持。