Android app shortcut is not working. Getting error "Failed to read the app data cannot start the app"

Viewed 3049

I have Created an App Shortcut of my app. But when i click on that shortcut it says "Failed to read the app data cannot start the app"

I have added

<uses-permission android:name="android.permission.INSTALL_SHORTCUT"/>

this line in my manifest file and also i have added

<meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts"/>

This line in my Main Intent filter:-

Here is my shortcuts.xml file:-

<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
    <shortcut
        android:enabled="true"
        android:icon="@drawable/ic_trackconsignment"
        android:shortcutId="tracking"
        android:shortcutShortLabel="@string/track"
        android:shortcutLongLabel="@string/track">

        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="in.vesolve.deliveryflyking.activities.revamp"
            android:targetClass="in.vesolve.deliveryflyking.activities.revamp.ConsignmentTrackActivity"
            />
    </shortcut>
</shortcut>

Output : - Shortcut Option
Result

My device : Relame 7 , Android 10 , Realme UI 1.0

Thanks in Advance :)

2 Answers

In Android manifest file, Add the below code in the launcher activity tag

android:exported="true"

Your applicationId in build.gradle and targetPackage in xml/shortcuts.xml should be same.

For example(Assuming as per your code snippet):

applicationId "in.vesolve.deliveryflyking" in build.gradle.

Then update your target package in shortcuts.xml

android:targetPackage="in.vesolve.deliveryflyking"
android:targetClass="in.vesolve.deliveryflyking.activities.revamp.ConsignmentTrackActivity"
Related