Android Shortcuts - App isn't installed error even though targetPackage and targetClass are correct

坚强是说给别人听的谎言 提交于 2020-01-04 04:00:07

问题


I tried implementing the Android Shortcuts when holding the icons in the home screen. But when I try to launch them I get an

"App isn't installed" Toast

This is my shortcuts.xml:

<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">

    <shortcut
        android:icon="@drawable/plus_black"
        android:shortcutId="add_sub"
        android:shortcutLongLabel="@string/shortcut_add_sub_long"
        android:shortcutShortLabel="@string/shortcut_add_sub">

        <intent
            android:action="android.intent.action.VIEW"
            android:targetClass="com.dancam.subscriptions.AddSubscription.AddSubscription"
            android:targetPackage="com.dancam.subscriptions.AddSubscription" />
    </shortcut>

    <shortcut
        android:icon="@drawable/pen"
        android:shortcutId="create_sub"
        android:shortcutLongLabel="@string/shortcut_create_sub_long"
        android:shortcutShortLabel="@string/shortcut_create_sub">

        <intent
            android:action="android.intent.action.VIEW"
            android:targetClass="com.dancam.subscriptions.CreateSubscription.CreateSubscription"
            android:targetPackage="com.dancam.subscriptions.CreateSubscription" />
    </shortcut>
</shortcuts>

I have already looked at this question but I couldn't find a suitable solution.

This is how my package/class tree looks like:

Any clue on how to fix this?


回答1:


Replace both android:targetPackage attribute values with your applicationId.

Here, "package" refers to the applicationId (a.k.a., package name), not the Java package of the class.



来源:https://stackoverflow.com/questions/48695766/android-shortcuts-app-isnt-installed-error-even-though-targetpackage-and-targ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!