You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自定义URL scheme调起App时ADB测试抛出java.lang.IllegalArgumentException异常

错误原因排查

1. ADB命令参数错误

你当前使用的命令里存在多余的无意义-参数,且没有正确使用指定URI的-d参数,这是直接触发Unknown option: -报错的原因。
原错误命令:

adb shell am start -W -a android.intent.action.VIEW - "onionmarkethost://onionmarket.open" kr.gowoonwoori.oniontime

其中单独的-不属于am start的合法参数,系统解析时无法识别该选项抛出异常。

2. AndroidManifest.xml配置与测试URI不匹配

你的intent-filter中data标签的scheme和host配置和你测试用的URI完全颠倒:

  • 你当前配置的scheme是onionmarket.open,host是onionmarkethost,对应合法URI格式为 onionmarket.open://onionmarkethost
  • 你测试用的URI是onionmarkethost://onionmarket.open,反过来把host写在了scheme的位置,scheme写在了host的位置,就算命令改对也无法匹配调起。

修正方案

第一步:修正配置(二选一即可)

方案A:保持你测试用的URI不变,修改data标签配置:

<activity android:name=".schema.SchemaActivity">
            <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:host="onionmarket.open"
                    android:scheme="onionmarkethost" />

            </intent-filter>
        </activity>

方案B:保持现有Manifest配置不变,后续测试用URI改为onionmarket.open://onionmarkethost

第二步:修正ADB测试命令

修改后正确的命令格式(以方案A的URI为例,选方案B则替换为对应URI即可):

adb shell am start -W -a android.intent.action.VIEW -d "onionmarkethost://onionmarket.open" kr.gowoonwoori.oniontime

核心改动是把原来的无用-替换成指定data URI的参数-d。

内容的提问来源于stack exchange,提问作者Mary Kim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 02:06:04