Issue id: AppLinkUrlError 应用intent-filter 配置深链接 URL 问题分析 | AndroidManifest

AndroidManifest.xml 配置文件中,对 activity 组件进行声明的时候,独立应用在 IDE 显示 intent-filter 报错,但不影响实际编译,因为是系统应用,肯定会有此 URL 的存在。

AOSP 源码:

XML 复制代码
        <activity android:name="Settings$ApnEditorActivity"
                android:configChanges="orientation|keyboardHidden|screenSize"
                android:exported="true"
                android:label="@string/apn_edit">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/telephony-carrier" />
            </intent-filter>

            <intent-filter>
                <action android:name="android.intent.action.INSERT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.dir/telephony-carrier" />
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.network.apn.ApnEditor" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_network"/>
        </activity>

AndroidManifest.xml

问题

红线说明:

Missing URL More... (Ctrl+F1)

Inspection info: Ensure your intent filter has the documented elements for deep links, web links, or Android App Links.

Issue id: AppLinkUrlError

More info: https://developer.android.com/training/app-links https://g.co/AppIndexing/AndroidStudio

Vendor: Android Open Source Project

Contact: https://groups.google.com/g/lint-dev

Feedback: https://issuetracker.google.com/issues/new?component=192708
Missing URL 的完整说明

IDE提示的解决建议中,set scheme是没有用的,通过忽略的配置可以不显示红线
IDE提示的解决建议

解决方案

intent-filter 配置tools:ignore="AppLinkUrlError"

显示正常代码:

XML 复制代码
            <intent-filter tools:ignore="AppLinkUrlError">
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/telephony-carrier" />
            </intent-filter>

LinkUrl介绍

AppLinkUrlError 错误

AppLinkUrlError 是与 Android 应用的深度链接(Deep Linking)和应用链接(App Links)相关的一个错误。该错误通常指示在尝试解析或打开某个特定的 URL 时出现了问题,这些问题可能导致链接无法正确打开到指定的应用或页面。

应用中的深链接 URL 可能存在多种问题,这些问题可能会导致用户无法正确访问应用的特定内容或功能。以下是一些常见的深链接相关问题:

  1. URL 格式不正确
  • 深链接的格式必须符合 URI 标准。如果 URL 中包含非法字符、拼写错误或格式不符合规范,可能导致链接无效。
  1. 未注册的深链接
  • 如果应用未正确在 Manifest 文件中声明其深链接,系统将无法识别并处理这些链接。这可能会导致用户点击链接后出现错误页面或无法打开应用。
  1. 不匹配的 URI 模式
  • 应用可能设置了特定的 URI 模式(例如:https://www.example.com/path),如果请求的链接不符合这些模式,应用将无法处理请求。
  1. 缺少必要的参数
  • 深链接通常需要附加参数(例如,ID 或查询字符串)以导向特定的内容。如果缺少这些必要的参数,用户可能无法访问正确的页面或功能。
  1. 授权和权限问题
  • 某些深链接可能需要用户授权,或者依赖于用户的登录状态。如果用户未登录或未授权,深链接可能无法正常工作。
  1. 平台兼容性
  • 不同平台或操作系统版本可能对深链接的支持程度不同。某些老旧版本的 Android 或 iOS 可能不完全支持深链接功能。
  1. 过期的链接
  • 如果深链接指向的内容已被删除或移除,用户在访问时将得到一个错误页面(例如 404 Not Found)。
  1. App 版本不兼容
  • 深链接可能在特定版本的应用中有效。如果用户安装的应用版本不支持该深链接指向的功能或内容,链接将无法正常工作。
  1. 网络问题
  • 在某些情况下,用户的网络连接问题可能导致深链接无法成功打开应用。
相关推荐
androidwork1 小时前
深入解析内存抖动:定位与修复实战(Kotlin版)
android·kotlin
梦天20151 小时前
android核心技术摘要
android
szhangbiao3 小时前
“开发板”类APP如果做屏幕适配
android
高林雨露4 小时前
RecyclerView中跳转到最后一条item并确保它在可视区域内显示
android
移动开发者1号6 小时前
ReLinker优化So库加载指南
android·kotlin
山野万里__7 小时前
C++与Java内存共享技术:跨平台与跨语言实现指南
android·java·c++·笔记
Huckings7 小时前
Android 性能问题
android
移动开发者1号7 小时前
剖析 Systrace:定位 UI 线程阻塞的终极指南
android·kotlin
移动开发者1号7 小时前
深入解析内存抖动:定位与修复实战(Kotlin版)
android·kotlin
whysqwhw7 小时前
OkHttp深度架构缺陷分析与革命性演进方案
android