android - Android 资源链接失败“@colors/blue”与属性资源 (attr) 引用不兼容
问题描述
Android 资源链接失败“@colors/blue”与属性资源 (attr) 引用不兼容。
我正在尝试为 firebase 推送通知图标设置自定义颜色。这是我的 config.xml 中给我不兼容错误的部分。
<platform name="android">
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
</edit-config>
<config-file parent="./application" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android">
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/push" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@colors/blue" />
</config-file>
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
<resource-file src="google-services.json" target="app/google-services.json" />
<allow-intent href="market:*" />
<icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
<icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
<icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
<icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
<icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
<icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
<splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
<splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
<splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
<splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
<splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
<splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
<splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
<splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
<splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
<resource-file src="resources/android/push-icon/drawable-mdpi-icon.png" target="app/src/main/res/drawable-mdpi/push.png" />
<resource-file src="resources/android/push-icon/drawable-hdpi-icon.png" target="app/src/main/res/drawable-hdpi/push.png" />
<resource-file src="resources/android/push-icon/drawable-xhdpi-icon.png" target="app/src/main/res/drawable-xhdpi/push.png" />
<resource-file src="resources/android/push-icon/drawable-xxhdpi-icon.png" target="app/src/main/res/drawable-xxhdpi/push.png" />
<resource-file src="resources/android/push-icon/drawable-xxxhdpi-icon.png" target="app/src/main/res/drawable-xxxhdpi/push.png" />
<resource-file src="resources/android/xml/colors.xml" target="app/src/main/res/xml/colors.xml" />
</platform>
这是我的 AndroidManifest.xml 的相应部分
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@colors/blue" />
colors.xml 文件的完整路径是:
资源/android/xml/colors.xml
目标生成的路由是:
应用程序/src/main/res/xml/colors.xml
最后是colors.xml文件代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="blue">#38a8ff</color>
</resources>
谢谢
解决方案
它应该color
没有s
:
android:resource="@color/blue"
推荐阅读
- ffmpeg - ffplay 启动时间与指定帧率成正比
- angular - 将值分配到导入的数据模型中
- ios - 向 LSApplicationQueriesSchemes 添加了方案,但 canOpenURL 仍然失败
- python-3.x - 在未安装 Python 的机器上运行 Python 脚本
- java - 当我尝试发送要在检票口网页上显示的消息时无法打开 IWebSocketConnection
- c# - 无法读取asp.net核心中请求的所有cookie
- javascript - Salesforce LWC - 在数据列表元素上使用 querySelector 时出现错误消息
- google-sheets - 如何在Google表格中找到另一行中有数字的行的总和
- python - scrapy 已安装但无法导入
- apache-spark - read parquet 时 read.partitions optin 有什么用