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

Android 14下React Native使用Linking.openUrl打开DeepLink报错求助

问题描述

在React Native应用中尝试打开DeepLink时触发错误:

[Error: Could not open URL 'micoope://app/cuenta/token': No Activity found to handle Intent { act=android.intent.action.VIEW dat=micoope://app/... }]

已知这是Android 14的新安全策略导致,但不确定是需要自己修改项目里的显式Intent创建(也不知道改哪个文件),还是该由React Native团队处理。附当前AndroidManifest文件中MainActivity的配置:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustResize"
    android:exported="false"
    android:screenOrientation="portrait">
    <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="micoope" android:host="app" />
    </intent-filter>
</activity>
解决步骤
  1. 修正android:exported属性
    Android 14要求所有包含Intent Filter的Activity必须设置android:exported="true"——因为这类Activity需要接收外部应用或系统发来的Intent。你当前的MainActivity配置里exported是false,这直接导致系统无法找到并启动它处理DeepLink。把这个属性改成true:
android:exported="true"
  1. 确认跳转逻辑(自定义场景)
    如果是你自己在RN代码外实现了跳转逻辑,比如自定义原生模块,要确保用的是隐式Intent(DeepLink靠scheme匹配,不需要指定具体Activity类名)。Kotlin示例代码:
val intent = Intent(Intent.ACTION_VIEW).apply {
    data = Uri.parse("micoope://app/cuenta/token")
    addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
context.startActivity(intent)

如果用的是RN自带的Linking.openURL(),底层已经处理了Intent创建,不需要额外修改原生代码。

  1. 验证配置生效
    修改AndroidManifest后重新打包安装,也可以用adb命令直接测试:
adb shell am start -W -a android.intent.action.VIEW -d "micoope://app/cuenta/token" com.your.package.name

替换com.your.package.name为你应用的包名,看是否能正常启动MainActivity。

说明

这个问题不需要React Native团队处理,是你项目的AndroidManifest配置不符合Android 14的安全要求导致的。修正exported属性就能解决核心问题,RN的DeepLink机制本身已经适配了Android 14规则。

内容的提问来源于stack exchange,提问作者Germán Sager

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 00:52:32