首页 > 解决方案 > 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>

谢谢

标签: androidfirebasecordovaionic-frameworkfirebase-cloud-messaging

解决方案


它应该color没有s

android:resource="@color/blue"

推荐阅读