android - 为什么错误 :(2) No resource identifier found for attribute 'shortcutShortLabel' in package 'android' when creating shourtcut in Android7?

标签 android

当我创建快捷方式时,请引用 developer.android.com, 我写的代码在下面

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
    android:enabled="true"
    android:icon="@drawable/share"
    android:shortcutId="search"
    android:shortcutShortLabel="@string/recommend_us"
    android:shortcutLongLabel="@string/recommend_to_friend"
    android:shortcutDisabledMessage="@string/bind_unbound">
    <intent
        android:action="android.intent.action.VIEW"
        android:targetPackage="com.example.myapplication"
        android:targetClass="com.yidian.news.ui.search.SearchChannelActivity" />
</shortcut>
<!-- Specify more shortcuts here. -->

一个简单的。但是当我构建项目时,出现错误消息说

错误:(2) 在包“android”中找不到属性“shortcutId”的资源标识符

错误:(2) 在包“android”中找不到属性“shortcutShortLabel”的资源标识符

错误:(2) 在包“android”中找不到属性“shortcutLongLabel”的资源标识符 错误:(2) 在包“android”中找不到属性“shortcutDisabledMessage”的资源标识符

这是为什么

已升级所有 Android SDK 和工具

最佳答案

快捷方式需要 Android 7.1。即,API 级别 25

关于android - 为什么错误 :(2) No resource identifier found for attribute 'shortcutShortLabel' in package 'android' when creating shourtcut in Android7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41011312/

相关文章:

java - 如何在不同线程的回调内通知 ArrayAdapter 中的DataSetChanged? - 安卓

Android 小部件不显示它的属性我要写时的建议

android - 无法在 kotlin `when` 表达式中使用 string.contains()

java - Gmail抽屉导航效果

android - Android Studio:Gradle项目同步失败

android - DialogFragment 使用接口(interface)回调到 Target Fragment

java - 注释掉 "@Override"是否安全?

Android Room 迁移测试 : discrepancy in primary key position causes unwarranted test failures

android - 如果我想使用蓝牙和 Target SDK 31 但我的最低 SDK 是 23,我需要在 Android 上获得什么权限?

java - 在 Google map 中查找最近的公交站/中途停留地(公共(public)汽车、火车等)