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:
The best solution for android studio is explained here: https://code.tutsplus.com/tutorials/how-to-enable-deep-links-on-android--cms-26317
TLDR : Android Studio --> Run --> Edit Configurations
Change Launch in Launch Options to "URL" and enter in the text field URL the correct url: "something://"
Just in case someone else has the problem that I had, namely that adb shell am start ...
does not work, if you have a file:///...
or content://...
URI in your intent filter that has a mime type specified, for example
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="text/plain" />
<data android:host="*" />
</intent-filter>
You need to specify the mime type on the command line by using the -t parameter:
adb shell am start -W -a android.intent.action.VIEW -d "file:///sdcard/myfolder/myfile.txt" -t "text/plain" com.myapp
or else you get the same error message as the OP.
Based on the experience I just had I recommend using this list of available adb commands. It seems to be more recent than the help texts from the shell of my test device running Android 8.
Here is the command
adb shell am start -d your-deep-link
Example
adb shell am start -d rm://yoursettingpage/v1
Try this:
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d 'yourdeeplink'
-a android.intent.action.VIEW -> action -c android.intent.category.BROWSABLE -> category -d 'deeplink' -> data
and also you need to install the app first in order to register the deeplink.
Testing deep-linking by running adb shell command seems troublesome to me. So I tried an Easy Solution to reduce my task and time to test deep-linking multiple time using .bat
file.
Step 1: First create a .txt file and paste here your ADB command -
adb shell am start -W -an android.intent.action.VIEW -d <Your URL> <Your Package>
and save the file changing .txt
extension into .bat
. Now you have just created your bat file to test deeplink. Try to use just one letter to name the bat file (Like I named d.bat
, "d" for "deeplinking" for easy understanding) because it reduce your time of typing.
Step 2: Now open your terminal
in Android studio and go to your bat file location and just type your file name (without extension) and press enter. For example cd your/bat/file/location/d
here suppose "d" is your bat file name.
It will work spiffy!