Cordova-plugin-firebase: Android 状态栏图标 - 全白

创建于 2016-09-13  ·  25评论  ·  资料来源: arnesson/cordova-plugin-firebase

你好,
我一直在试图改变发送推送通知时显示在 android 状态栏上的图标。 这是正在发生的事情的一个例子:

screenshot_2016-09-13-08-53-22

如您所见,我的应用程序的图标不是透明图像。 如果我将其更改为透明图像,则推送图标看起来不错,但应用程序图标现在是透明图像,这不是我想要的。 我尝试了不同的文件名变体,但似乎没有任何效果。 查看代码时,第 73 行的 src/android/FirebasePluginMessagingService.java 有:
.setSmallIcon(getApplicationInfo().icon)

我是否正确地说您不能设置与应用程序图标不同的图标?
是否可以为状态栏图标设置不同的文件?
或者关于如何解决这个问题的任何其他建议?

最有用的评论

谢谢@blckshrk !! 我终于让它工作了!

我正在使用Ionic v2[email protected]
离子:2.2.2
科尔多瓦:6.5.0
npm:4.6.1

  1. 安装自定义配置插件:
    $ ionic plugin add cordova-custom-config --fetch --save

  2. https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.jshttps://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.js下载到项目根目录中名为“package-hooks”(或任何您想要的)的新目录。
    package-hooks/android_custom_resources.js
    package-hooks/android_custom_values.js

  3. 在项目根目录(不在平台内部)中创建以下目录和文件:
    resources/android/custom/notification_icon.png
    resources/android/values/styles.xml

notification_icon.png是您的 Android >= API 21 通知图标。 我的是 144x144 像素,看起来很棒。

styles.xml包含:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#FF8614</color>
</resources>
  1. 编辑 config.xml。 重要提示:确保在小部件标记中添加该命名空间。
    <widget ... xmlns:android="http://schemas.android.com/apk/res/android">
        <platform name="android">
            <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
            <hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
            <config-file parent="./application" target="AndroidManifest.xml">
                <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
                <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
            </config-file>
        </platform>
    <widget>

就这样!

所有25条评论

我没有对此进行测试,但您应该能够通过创建所有所需尺寸的 fcm_push_icon.png 来设置自定义图标。 默认情况下,如果 fcm_push_icon.png 不存在,将使用应用程序图标。 图标应该在 android/res 文件夹树中。

您可以使用它来生成所有不同的大小: http ://romannurik.github.io/AndroidAssetStudio/icons-notification.html

你好,我们面临同样的问题。 我们尝试在 android/res 文件夹树中放置fcm_push_icon.png图标,但通知图标仍然是白色的。

@MikeBateman你找到解决方案了吗?

您好,要解决此问题,您可以更改应用程序的目标 sdk,请检查此问题,但这当然不是合适的解决方案。

我一直在研究并得到了这个解决方案:

转到这条路线 src/android/FirebasePluginMessagingService.java 并找到这条线.setSmallIcon(getApplicationInfo().icon) (就像@MikeBateman提到的那样),现在添加一个条件来检查应用程序是否在 android lollipop+ 中运行,如果为真则通知如果不是,应该使用材料设计图标,它将使用默认应用程序的图标,代码:

...

  .setSmallIcon(getNotificationIcon())
...

//At the end of FirebasePluginMessagingService.java 
    private int getNotificationIcon() {
        boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
        System.out.println("SCLMTEST >lollipop?:"+useWhiteIcon);
        return useWhiteIcon ? R.drawable.myMaterialIcon: getApplicationInfo().icon;
    }

我认为最好的方法是将您的材料设计图标放在 myappresources 中,插件自己完成这项工作,现在我不知道该怎么做,如果有人可以的话,那就太好了,希望对您有所帮助! @delphaber

固定在 33c52c7e8a1835d5f595e58eaef43e4f49b4b23a

如果存在,插件现在将在 drawable 中使用 notification_icon。 否则它将使用默认的应用程序图标

嘿,

我不明白。 我尝试在每个可绘制文件夹(每种尺寸)中放置一个notification_icon.png ,但插件仍然使用默认的(应用程序图标)。 我错过了什么吗?

谢谢!

@blckshrk抄送/ @robertarnesson

在更新了 Android src 文件并添加了所有notification_icon.png文件后,我遇到了同样的事情,我仍然只是看到白色方块。 我最终遵循了这里的建议: http :

首先,我必须更新我的 Google 存储库,以使最新的 Firebase SDK 在我的计算机上是最新的。 在撰写本文时,这是com.google.firebase:firebase-core 9.8.0 版,我正在让它工作。 (我之前是9.4.0)

然后我将此添加到我的AndroidManifest.xml

<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />

如果您想使用他们的选项来更改default_notification_color您需要添加以下内容。 我们的图标是带有透明背景的白色图标,所以我们添加了自己的颜色,在锁定屏幕上很好看。

<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/orange" />

您还需要添加一个res/values/colors.xml文件,其中包含以下内容,如果您正在设置背景,当然可以选择您自己的颜色:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="orange">#FF8614</color>
</resources>

这一切都适用于 Firebase 9.8.0

@blckshrk你如何将图标添加到项目中? 您需要使用项目的 config.xml 将它们添加到资源中。 据我所知,仅将它们放在文件夹中不会使它们对代码可见

目前我正在使用 Ionic 2 创建我的应用程序并执行以下操作:
我已将图标文件添加到 ionic 的 res 文件夹中,因此如果我运行命令ionic resources ,则会创建不同屏幕尺寸的图像。

这也将图像路径添加到config.xml文件。

有人可以详细回答一下具体需要做什么吗..

  • 就像需要在哪个文件夹中添加文件一样,对于 Android
  • 是否需要将它们添加到 config.xml 文件中
  • 文件的图像大小是多少

我不了解本机 Android 代码和文件夹结构,因此请相应地回复。

-谢谢

实际上就像@prantikv我有点迷路了。 我使用 Ionic 1(但工作流程相同)。 我尝试将我的图标放入res/drawable/并使用cordova-custom-config在我的AndroidManifest.xml中添加<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" /> $ (直接在manifest节点中),但是没有按预期工作。

@gylippus我没有得到com.google.firebase:firebase-core部分。 你如何检查版本?

多谢你们!

@robertarnesson @gylippus你有一个可行的例子吗?

我设法使它与cordova-custom-config一起工作

<config-file parent="./application" target="AndroidManifest.xml">
          <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>

platforms/android/res/drawable/notification_icon.png

非常感谢你的帮助 !

如果notification_icon.png位于根(或resources )文件夹中(因为它是用于配置文件)。 怎么想的?

@blckshrk
如您所述,我尝试添加以下代码

<config-file parent="./application" target="AndroidManifest.xml">
          <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>

但是在构建过程中出现以下错误

:processDebugResources
E:\Development\IONIC 2\allcouriertracking\allcouriertracking5\platforms\android\res\xml\config.xml:57 : AAPT: Error parsing XML: unbound prefix


 FAILED

FAILURE: Build failed with an exception.


:processDebugResources
E:\Development\IONIC 2\allcouriertracking\allcouriertracking5\platforms\android\res\xml\config.xml:57 : AAPT: Error parsing XML: unbound prefix


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'I:\DEVELOPMENT PROGRAMS\android-sdk-windows\build-tools\24.0.3\aapt.exe'' finished with non-zero exit value 1

然后我手动将以下内容添加到 AndroidManifest.xml
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />

它适用于 Android 4.4 但不适用于 Android 5.1。

你为哪个版本构建的?
另外,您是在所有drawable文件夹中添加了notification_icon.png $ 文件还是只添加了一个?

@prantikv您是否安装了https://github.com/dpa99c/cordova-custom-config

实际上我使用这个钩子https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.js自动将notification_icon.png文件移动到每个可绘制文件夹中。

基本上我在<platform name="android">节点中有这个:

<hook src="hooks/after_prepare/android_custom_resources.js" type="after_prepare"/>
<config-file parent="./application" target="AndroidManifest.xml">
    <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon" />
</config-file>

编辑

我还设法通过使用这个钩子https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.js@gylippus提出的解决方案来处理颜色(谢谢!)

@blckshrk是的,我确实安装了插件..你能告诉我你正在使用的图像大小吗..图像尺寸以及以 KB 为单位的大小。
以及您测试过的平台。

对此有何更新? 20天了还是没有解决办法? 如果它仍然是一个问题,它不能关闭?!

我有同样的问题,我可以从服务器端解决它。 我手动将图标放置在名为 notification_icon.png 的 platform-android 文件夹内的可绘制文件夹中。
通过 Firebase 控制台,我一直看到错误的图标,但在自己的服务器上,我将以下内容作为请求正文发送:

$fields = array(
  "registration_ids" => "array of registration ids",
  "notification" => array(
    "body"=>"message to send as a body",
    "icon"=>"notification_icon",
    "color"=>"your color in hex"
  ),
  "priority"=>10
);

希望这有帮助

实际上,经过一些记录和阅读后,在我看来,FirebasePluginMessagingService.java / sendNotification 中的整个 notificationBuilder 代码没有实际意义,因为当有通知有效负载时它永远不会运行。 除了图标问题,我也开始怀疑这是因为 notificationBuilder 代码执行了 .setSound(defaultSoundUri) 但是当通知到达托盘时它永远不会播放。

这就是上面 sergiojup 的解决方案有效的原因,因为通知不是由插件代码构建的,而是由 FCM 本身构建的,它从通知有效负载中获取指令。

至于为什么.. 在 Android 上,仅在以下情况下调用 onMessageReceived:
*)只有一个通知有效载荷,应用程序在前台
*)有一个通知有效负载和数据有效负载,应用程序在前台
*) 只有数据有效负载,应用程序位于前台或后台

因此,在这些情况下,不会调用 onMessageReceived:
*)只有一个通知有效载荷,应用程序在后台
*)有一个通知有效负载和数据有效负载,并且应用程序在后台

查看代码,让插件构建通知的唯一方法是仅使用数据有效负载,它同时具有标题和文本属性,而应用程序在后台。

谢谢@blckshrk !! 我终于让它工作了!

我正在使用Ionic v2[email protected]
离子:2.2.2
科尔多瓦:6.5.0
npm:4.6.1

  1. 安装自定义配置插件:
    $ ionic plugin add cordova-custom-config --fetch --save

  2. https://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_resources.jshttps://github.com/driftyco/ionic-package-hooks/blob/master/android_custom_values.js下载到项目根目录中名为“package-hooks”(或任何您想要的)的新目录。
    package-hooks/android_custom_resources.js
    package-hooks/android_custom_values.js

  3. 在项目根目录(不在平台内部)中创建以下目录和文件:
    resources/android/custom/notification_icon.png
    resources/android/values/styles.xml

notification_icon.png是您的 Android >= API 21 通知图标。 我的是 144x144 像素,看起来很棒。

styles.xml包含:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="red">#FF8614</color>
</resources>
  1. 编辑 config.xml。 重要提示:确保在小部件标记中添加该命名空间。
    <widget ... xmlns:android="http://schemas.android.com/apk/res/android">
        <platform name="android">
            <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
            <hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
            <config-file parent="./application" target="AndroidManifest.xml">
                <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
                <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
            </config-file>
        </platform>
    <widget>

就这样!

我不明白在 config.xml 中的何处添加以下内容? 提示? 另外,我对 XML 不是很熟悉,我应该在命名空间中添加什么? @shamank

<widget ... xmlns:android="http://schemas.android.com/apk/res/android"> <platform name="android"> <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/> <hook src="package-hooks/android_custom_values.js" type="after_prepare"/> <hook src="package-hooks/android_fixes.js" type="after_prepare"/> <config-file parent="./application" target="AndroidManifest.xml"> <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/> <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/> </config-file> </platform> <widget>

@Rockforced抱歉,这些天我不在。 看看原始文件(当然有一些替换的东西)。 希望能帮助到你。

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.example" version="1.0.20" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    <name>Test</name>
    <description>Blabla.</description>
    <author email="[email protected]" href="https://example.com/">Example</author>
    <content src="index.html"/>
    <access origin="*"/>
    <allow-navigation href="http://ionic.local/*"/>
    <allow-navigation href="http://192.168.0.1:8100"/>
    <allow-intent href="http://*/*"/>
    <allow-intent href="https://*/*"/>
    <allow-intent href="tel:*"/>
    <allow-intent href="sms:*"/>
    <allow-intent href="mailto:*"/>
    <allow-intent href="geo:*"/>
    <platform name="android">
        <allow-intent href="market:*"/>
        <hook src="package-hooks/android_custom_resources.js" type="after_prepare"/>
        <hook src="package-hooks/android_custom_values.js" type="after_prepare"/>
        <hook src="package-hooks/android_fixes.js" type="after_prepare"/>
        <config-file parent="./application" target="AndroidManifest.xml">
            <meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notification_icon"/>
            <meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/red"/>
        </config-file>
        <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="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"/>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*"/>
        <allow-intent href="itms-apps:*"/>
        <icon height="57" src="resources/ios/icon/icon.png" width="57"/>
        <icon height="114" src="resources/ios/icon/[email protected]" width="114"/>
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40"/>
        <icon height="80" src="resources/ios/icon/[email protected]" width="80"/>
        <icon height="120" src="resources/ios/icon/[email protected]" width="120"/>
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50"/>
        <icon height="100" src="resources/ios/icon/[email protected]" width="100"/>
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60"/>
        <icon height="120" src="resources/ios/icon/[email protected]" width="120"/>
        <icon height="180" src="resources/ios/icon/[email protected]" width="180"/>
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72"/>
        <icon height="144" src="resources/ios/icon/[email protected]" width="144"/>
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76"/>
        <icon height="152" src="resources/ios/icon/[email protected]" width="152"/>
        <icon height="167" src="resources/ios/icon/[email protected]" width="167"/>
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29"/>
        <icon height="58" src="resources/ios/icon/[email protected]" width="58"/>
        <icon height="87" src="resources/ios/icon/[email protected]" width="87"/>
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640"/>
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750"/>
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242"/>
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536"/>
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768"/>
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640"/>
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320"/>
    </platform>
    <preference name="webviewbounce" value="false"/>
    <preference name="UIWebViewBounce" value="false"/>
    <preference name="DisallowOverscroll" value="true"/>
    <preference name="android-minSdkVersion" value="16"/>
    <preference name="android-targetSdkVersion" value="23"/>
    <preference name="BackupWebStorage" value="none"/>
    <preference name="SplashMaintainAspectRatio" value="true"/>
    <preference name="SplashReloadOnOrientationChange" value="true"/>
    <preference name="SplashScreenDelay" value="3000"/>
    <preference name="FadeSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="0"/>
    <preference name="orientation" value="portrait"/>
    <preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
    <preference name="SplashScreen" value="screen"/>
    <preference name="AutoHideSplashScreen" value="false"/>
    <preference name="KeyboardDisplayRequiresUserAction" value="false"/>
    <preference name="loadUrlTimeoutValue" value="700000"/>
    <feature name="StatusBar">
        <param name="ios-package" onload="true" value="CDVStatusBar"/>
    </feature>
    <feature name="InAppBrowser">
        <param name="ios-package" value="CDVInAppBrowser"/>
        <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
    </feature>
    <plugin name="cordova-plugin-app-event" spec="~1.2.0"/>
    <plugin name="cordova-plugin-device" spec="~1.1.3"/>
    <plugin name="cordova-plugin-console" spec="~1.0.4"/>
    <plugin name="cordova-plugin-whitelist" spec="~1.3.2"/>
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.2"/>
    <plugin name="cordova-plugin-statusbar" spec="~2.2.2"/>
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
    <plugin name="cordova-plugin-geolocation" spec="~2.4.1"/>
    <plugin name="cordova-plugin-compat" spec="~1.1.0"/>
    <plugin name="cordova-plugin-inappbrowser" spec="~1.6.1"/>
    <plugin name="cordova-plugin-nativestorage" spec="~2.2.2"/>
    <plugin name="cordova-plugin-firebase" spec="~0.1.20"/>
    <plugin name="cordova.plugins.diagnostic" spec="~3.0.4"/>
    <plugin name="cordova-plugin-googlemaps" spec="~1.4.0">
        <variable name="API_KEY_FOR_ANDROID" value="blabla"/>
        <variable name="API_KEY_FOR_IOS" value="blabla"/>
    </plugin>
    <plugin name="ionic-plugin-deeplinks" spec="~1.0.14">
        <variable name="URL_SCHEME" value="blabla"/>
        <variable name="DEEPLINK_SCHEME" value="https"/>
        <variable name="DEEPLINK_HOST" value="www.blabla.com"/>
        <variable name="ANDROID_PATH_PREFIX" value="/"/>
    </plugin>
    <plugin name="cordova-custom-config" spec="~3.2.0"/>
    <icon src="resources/ios/icon/[email protected]"/>
    <engine name="android" spec="~6.2.2"/>
</widget>

@shamank 非常感谢你。 整天都在与 0.1.24 版本作斗争,没有任何运气,您的解决方案有效。 你能告诉我为什么这会使自定义图标起作用吗? 我非常仔细地按照阅读中的说明进行操作,但它只显示了一个灰色的图标。 您的解决方案立即奏效......我只想知道为什么!

@jskidd3很高兴它有帮助! 这真的很简单。 cordova-custom-config 插件允许您更改 Cordova 的每个平台的最终配置 (Info.plist / AndroidManifest.xml)。 因此,在 config-file 块中,您告诉插件的 Android 配置在“notification_icon”的新名称下的 drawables 目录中搜索“default_notification_icon”(如果我记得清楚,插件会处理文件扩展名)。 然后在下一个块中定义背景颜色(红色)。 现在您需要一种方法在构建时将该文件 (notification_icon.png) 放在正确的位置,因此您需要一个钩子来执行此操作。 那是android_custom_resources.js。 它获取 resources/android/custom/* 中的任何内容,并将其放入构建的可绘制目录中(您可以通过编辑脚本来更改它,但这对于这个任务来说是可以的)。 与其他配置样式类似。 您创建了这个 styles.xml 文件; 定义颜色(我将其命名为“红色”,但它可以是您想要的任何颜色),然后 android_custom_values.js 将其复制到构建的目录“platforms/android/res/values”。 最后,在 config.xml 中绑定这些脚本以在某个时刻运行。 对于这个任务,它们需要被复制“after_prepare”,这意味着,在 Cordova 准备好构建之后(再次,如果我没记错的话......你可以查看 Ionic 的包挂钩文档以获取更多详细信息/事件)。

@alexbonhomme的回答对我有用:) https://github.com/arnesson/cordova-plugin-firebase/issues/53#issuecomment -304573222

@shamank的决定部分对我有用。
我正在使用 Angular + Cordova。

一切正常,除了一件事:android_custom_resources.js 不会创建文件夹(drawable-ldpi、drawable-mdpi 等),如果文件夹不存在,也不会复制文件。

所以我删除了该脚本并在 config.xml 中使用:

注意:由于自定义更改,路径可能会有所不同,并且 [email protected] 和 > 在另一个地方有res/文件夹。

`

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-mdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-hdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xhdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xxhdpi/notification.png" />

    <resource-file src="res/custom/android/notification.png" target="app/src/main/res/drawable-xxxhdpi/notification.png" />`

无论如何,谢谢@alexbonhomme@shamank

对于@shamank的解决方案路径中的 Ionic 3(更具体地说是 cordova-android@7):
package-hooks/android_custom_resources.js package-hooks/android_custom_values.js
应更新,因为res文件夹现在在platforms/android/app/src/main/内。

  1. 转到package-hooks/android_custom_resources.js并更新
    var platformDir = 'platforms/android';

    var platformDir = 'platforms/android/app/src/main';

  2. 转到package-hooks/android_custom_values.js并更新
    var platformDir = platforms/android/res/values';

    var platformDir = 'platforms/android/app/src/main/res/values';

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

jdla1990 picture jdla1990  ·  4评论

Zrnik picture Zrnik  ·  3评论

dhavalsoni2001 picture dhavalsoni2001  ·  5评论

matthitachi picture matthitachi  ·  5评论

ghost picture ghost  ·  3评论