在启动器中显示静态快捷方式时出错

Error with shortcuts static to show in the launcher

我正在按照官方文档制作在启动器中显示的快捷方式。当我开始测试时,我收到此错误。我该如何解决?我做错了什么?

Error:(6, 23) No resource found that matches the given name (at 'icon' with value '@drawable/compose_icon').
Error:(8, 36) No resource found that matches the given name (at 'shortcutLongLabel' with value '@string/compose_shortcut_long_label1').

我的代码是这样的

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
    android:shortcutId="compose"
    android:enabled="true"
    android:icon="@drawable/compose_icon"
    android:shortcutShortLabel="@string/compose_shortcut_short_label1"
    android:shortcutLongLabel="@string/compose_shortcut_long_label1"
    android:shortcutDisabledMessage="@string/compose_disabled_message1">
    <intent
        android:action="android.intent.action.VIEW"
        android:targetPackage="com.example.myapplication"
        android:targetClass="com.example.myapplication.ComposeActivity" />
    <!-- If your shortcut is associated with multiple intents, include them
         here. The last intent in the list determines what the user sees when
         they launch this shortcut. -->
    <categories android:name="android.shortcut.conversation" />
</shortcut>
<!-- Specify more shortcuts here. -->

compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {

    minSdkVersion 15
    targetSdkVersion 25

您需要提供有效的图标和字符串资源。似乎您正在直接试用 documentation 中的示例。编译器不会指出这个文件中的错误,所以你需要小心你提到的资源。

具体来说,在您的字符串中定义 compose_shortcut_short_label1compose_shortcut_long_label1compose_disabled_message1 以及 compose_icon.

的有效可绘制资源

同时相应地更改 android:targetPackageandroid:targetClass 属性。