I am trying to test android deep link urls through adb to launch my app

前端 未结 11 673
孤街浪徒
孤街浪徒 2021-01-30 10:07

When I type the command in adb:

./adb shell am start -W -a android.intent.action.VIEW -d \"example:gizmos\" com.myapp

I get this error:

相关标签:
11条回答
  • 2021-01-30 10:42

    The command

    adb shell dumpsys package domain-preferred-apps
    

    is also very helpful to print all active deep link handlers known to the system. If your app is missing here, there's obviously something wrong with your deep link setup.

    0 讨论(0)
  • 2021-01-30 10:43

    You don't need to specify full path to your activity, but if you want to test whether you react properly to URI in your app just specify app package:

    adb shell am start -a android.intent.action.VIEW -d "example://gizmos" com.myapp
    

    Also there is bug in command you provided - there should be example://gizmos not example:gizmos

    0 讨论(0)
  • 2021-01-30 10:43

    As the other answer mentioned, it should be "example://gizmos" and not "example:gizmos"

    Alternatively, instead of using adb, you can test deep links directly on android using deep link tester app:

    https://play.google.com/store/apps/details?id=com.manoj.dlt

    No need to mention any package name or component name. Just type the deep link and fire.

    I've found testing deep links through adb to be cubersome and difficult at times. Hence, I've built this small app to do it.

    0 讨论(0)
  • 2021-01-30 10:46

    I found Savas Adar's answer the most friendly to use, also makes much more sense to have an inbuilt tool for that purpose.

    Just use that!

    I have three quick disclaimers about the App Links Assistant which are missing in his answer and a comment was too long.

    1. Open App Links Assistant. I couldn't find it in the Tools menu. So double press Shift and type App Link Assistant to run it from Android Studio

    2. Pressing "Run Test" would clear the edit text box so I found myself having to copy and paste my link every time I wanted to re-try the test. Foolish of myself not reading the text literally above it saying that after running a test a Run Configuration gets created with the previous url attached to it. (Top of the screen, left of the device menu). Just select the run configuration with the url you want.

    3. I found that pressing "Run Test" would restart the app unlike the ABD approach which is no biggie (just slower) until I wanted to debug. I ran the app in the debug mode and then pressed Run Test which would stop my debugging sessions and restart the app...

    Solution is to choose the Run Configuration from point 2, and just run it as a debug.

    0 讨论(0)
  • 2021-01-30 10:48

    Your command is incorrect because you are trying with an incorrect package name, Instead of com.myapp.activity.DeepLinkActivity you have to write only the package name specified in build gradle(Module: app) by 'application Id' e.g if your applicationId is com.companyname, then your command would be like this:

    adb shell am start -W -a android.intent.action.VIEW -d  "example://gizmos" com.companyname
    
    0 讨论(0)
  • 2021-01-30 10:53

    You can test your deeplink from Android Studio interface.

    1. Select Tools > App Links Assistant.
    2. Click Test App Links in the App Links Assistant.
    3. Enter the URL you want to test in the URL field, for example, http://recipe-app.com/recipe/grilled-potato-salad.
    4. Click Run Test.

    Take a look for learn how to implement applinks via Android Studio Interface. https://developer.android.com/studio/write/app-link-indexing#testindent

    0 讨论(0)
提交回复
热议问题