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

问题描述 投票:3回答:4

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

这是一个截图:

android android-drawable
4个回答
10
投票

打开你下载的drawable并用android:fillColor="@android:color/white"替换android:fillColor="#ffffff"。在向量drawable中,必须明确设置fillColor属性,而不是引用其他资源


6
投票

在build.gradle中添加以下行:

defaultConfig{
   vectorDrawables.useSupportLibrary = true
}

检查这个更多细节:Vector drawables overview


0
投票

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


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解决方案的替代方案,我设置了minSdkVersionto 21,问题解决了。

缺点是你失去了对SDK <16的设备的支持。

© www.soinside.com 2019 - 2024. All rights reserved.