如何更新NativeScript Android的应用程序图标

时间:2017-09-13 07:45:05

标签: android nativescript

我有一个已部署到PlayStore的应用。随着新的更新,我希望这个应用程序显示一个略微不同的图标和启动屏幕。

我的styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- theme to use FOR launch screen-->
    <style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>

        <item name="colorPrimary">@color/ns_primary</item>
        <item name="colorPrimaryDark">@color/ns_primaryDark</item>
        <item name="colorAccent">@color/ns_accent</item>

        <item name="android:windowBackground">@drawable/splash_screen</item>
        <item name="android:windowNoTitle">true</item>

        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowTranslucentStatus">true</item>

        <item name="android:windowFullscreen">true</item>
    </style>

    <style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
    </style>

    <!-- theme to use AFTER launch screen is loaded-->
    <style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>

        <item name="colorPrimary">@color/ns_primary</item>
        <item name="colorPrimaryDark">@color/ns_primaryDark</item>
        <item name="colorAccent">@color/ns_accent</item>

        <item name="android:windowFullscreen">false</item>
    </style>

    <style name="AppTheme" parent="AppThemeBase">
    </style>

    <!-- theme for actioon-bar -->
    <style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">@color/ns_primary</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.ActionBar</item>
        <item name="popupTheme">@style/ThemeOverlay.AppCompat</item>

    </style>

    <style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
    </style>
</resources>

我的colors.xml

<resources>
    <color name="ns_primary">#F5F5F5</color>
    <color name="ns_primaryDark">#757575</color>
    <color name="ns_accent">#33B5E5</color>
    <color name="ns_blue">#272734</color>
</resources>

来自我的AndroidManifest.xml

<application
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
>

我有很多drawable文件夹,其中.png'sicon.png中有一些splashscreen.9.png。现在,如果我只是尝试删除这些并将新的.png文件放入,我在尝试tns run android时会遇到异常。

我已经尝试删除平台并读取它(清理npm缓存)并删除.gradle目录。我还在我的根目录中搜索了.pngiconsplashscreen,没有找到其他图片(所有这些都是最新的)。

我不确定我还应该尝试什么,并且要求谷歌到目前为止没有帮助我。

错误:

15:25:01.117 [DEBUG] [org.gradle.api.Project] AAPT(QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}) discarded: Crunching C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.118 [QUIET] [system.out] Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT out(Facade for 1223856843): Crunching single PNG file: C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT out(Facade for 1223856843): -> QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT notify(QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}): Crunching single PNG file: C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.118 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT(QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}) discarded: Crunching single PNG file: C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT out(Facade for 1223856843):  Output file: C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT out(Facade for 1223856843): -> QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}
15:25:01.118 [DEBUG] [org.gradle.api.Project] AAPT notify(QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}):        Output file: C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.118 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':mergeF0F1F2F3DebugResources'
15:25:01.119 [DEBUG] [org.gradle.api.Project] AAPT(QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}) discarded:     Output file: C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png
15:25:01.119 [DEBUG] [org.gradle.api.Project] AAPT out(Facade for 1223856843): Done
15:25:01.119 [DEBUG] [org.gradle.api.Project] AAPT out(Facade for 1223856843): -> QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}
15:25:01.119 [DEBUG] [org.gradle.api.Project] AAPT notify(QueuedJob{
title=Cruncher notify_panel_notification_icon_bg.png,
task={from=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\res\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png, to=C:\Dev\biff\HandyApp\platforms\android\build\intermediates\res\merged\F0F1F2F3\debug\drawable-xhdpi-v4\notify_panel_notification_icon_bg.png},
future=com.google.common.util.concurrent.SettableFuture@9c66ab1}): Done
15:25:01.119 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :mergeF0F1F2F3DebugResources FAILED
15:25:01.119 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :mergeF0F1F2F3DebugResources (Thread[Daemon worker Thread 2,5,main]) completed. Took 7.194 secs.
15:25:01.119 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.45 completed (0 in use)
15:25:01.119 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker Thread 2,5,main]] finished, busy: 26.976 secs, idle: 0.069 secs
15:25:01.123 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:25:01.123 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:25:01.123 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:25:01.123 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
15:25:01.124 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':mergeF0F1F2F3DebugResources'.
15:25:01.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
15:25:01.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
15:25:01.126 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
15:25:01.127 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':mergeF0F1F2F3DebugResources'.

1 个答案:

答案 0 :(得分:2)

NativeScript4.x.x。及以上版本引入了CLI命令,用于自动生成和替换应用程序图标和启动屏幕。

要同时更改Android和iOS的应用程序图标

tns resources generate icons  ../myIcon.png

要同时更改Android和iOS的启动屏幕

tns resources generate splashes ../myImage.png --background "#FF00FF"

有关官方文档herehere中这些功能的更多信息。