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

Flutter Android应用Deep Link无法自动打开,求排查AndroidManifest配置

问题

在Flutter Android应用中使用uni_links插件实现Deep Link功能,已配置AndroidManifest文件,但仅当手动开启手机端「设置/应用/默认打开/打开支持的链接」后,链接「https://cloud.appwrite.io/....」才能唤起应用,请问AndroidManifest配置存在什么问题?

对应的AndroidManifest代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:label="concrete_sensors"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">

            <!-- !Deep Links -->
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
                <data
                    android:scheme="https"
                    android:host="cloud.appwrite.io" />
            </intent-filter>
            <!-- !Deep Links -->

            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

            </activity>
        
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>
问题分析与修复方案

你的配置核心问题是Android App Links自动验证未通过,导致系统未自动授予应用处理该链接的权限,必须手动开启。具体原因和修复步骤如下:

1. android:autoVerify="true" 触发了App Links验证,但缺少必要配置

当你给intent-filter添加android:autoVerify="true"时,Android会要求你的域名cloud.appwrite.io必须配置数字资产链接文件(assetlinks.json),否则验证失败,系统不会自动让应用接管该链接,只能手动开启权限。

2. 具体修复步骤

步骤一:添加manifest的package属性

你的AndroidManifest根标签缺少package属性,这是App Links验证和应用识别的必要信息,必须补充:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourcompany.concrete_sensors"> <!-- 替换为你的实际应用包名 -->

在cloud.appwrite.io域名的.well-known目录下放置assetlinks.json文件,内容格式如下:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "你的应用包名",
    "sha256_cert_fingerprints": ["你的应用签名的SHA256指纹"]
  }
}]
  • 包名:就是你刚才添加到manifest里的package值
  • SHA256指纹:可通过Android Studio的Build > Generate Signed Bundle/APK查看,或用命令行keytool -list -v -keystore 你的签名文件路径获取。

步骤三:验证文件可访问

确保通过https://cloud.appwrite.io/.well-known/assetlinks.json能直接访问到该文件,且内容无错误。

可选方案:改为普通Deep Link(跳过自动验证)

如果不需要系统直接跳转(允许点击链接时弹出应用选择器),可以移除android:autoVerify="true",修改后的intent-filter:

<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="https"
        android:host="cloud.appwrite.io" />
</intent-filter>

这样用户点击链接时会看到应用选择器,选择你的应用后即可唤起,无需手动开启权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 06:55:44