异常信息
尝试 Android 15 新增的更精确 Intent 解析的功能时,出现如下两种错误:
-
在 Android Studio(Android Studio Koala | 2024.1.1)中编辑 AndroidManifest.xml,添加 <uri-relative-filter-group>
标签时,提示如下错误提示:
Element uri-relative-filter-group is not allowed here
-
编译应用时提示如下错误:
> Task :app:processDebugResources FAILED
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\itmob.cn\\WorkSpace\\ComposeSample\\app\\src\\main\\AndroidManifest.xml","position":{"startLine":33,"startColumn":16,"endLine":37,"endColumn":44}}],"original":"ERROR: C:\\Users\\itmob.cn\\WorkSpace\\ComposeSample\\app\\src\\main\\AndroidManifest.xml:34:17-38:45: AAPT: error: unexpected element <uri-relative-filter-group> found in <manifest><application><activity><intent-filter>.\n ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\itmob.cn\\WorkSpace\\ComposeSample\\app\\src\\main\\AndroidManifest.xml","position":{"startLine":33,"startColumn":16,"endLine":37,"endColumn":44}}],"original":"ERROR: C:\\Users\\itmob.cn\\WorkSpace\\ComposeSample\\app\\src\\main\\AndroidManifest.xml:34:17-38:45: AAPT: error: unexpected element <uri-relative-filter-group> found in <manifest><application><activity><intent-filter>.\n ","tool":"AAPT"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
ERROR: C:\Users\itmob.cn\WorkSpace\ComposeSample\app\src\main\AndroidManifest.xml:34:17-38:45: AAPT: error: unexpected element <uri-relative-filter-group> found in <manifest><application><activity><intent-filter>.
ERROR: C:\Users\itmob.cn\WorkSpace\ComposeSample\app\src\main\AndroidManifest.xml:34:17-38:45: AAPT: error: unexpected element <uri-relative-filter-group> found in <manifest><application><activity><intent-filter>.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
解决方法
这是因为 UriRelativeFilterGroup
对更精确的 Intent 解析是从 Android 15 增加的新功能和 API,
- 当前最新的 Android Studio 稳定版本是 2024.1.1.13,它的 Manifest 编辑器不支持
<uri-relative-filter-group>
标签,对其支持是从 Android Studio Ladybug | 2024.1.3 Canary 1 开始的。
- 支持
UriRelativeFilterGroup
需要 AGP (Android Gradle Plugin) 的最低版本是 8.7.0-alpha01
解决方法:
- 确保使用的 Android Studio 是 Ladybug | 2024.1.3 Canary 1 及之后的版本(目前(2024年8月) Ladybug 还未推出稳定版,只能使用预览版)
- 确保使用 AGP 8.7.0-alpha01 或更新版本
其他
Issue Tracker: Supprot uri-relative-filter-group in manifest editor
Android 15 新功能和 API 详解:更精确的 Intent 解析,UriRelativeFilterGroup 和 UriRelativeFilter
Android 15 功能和变更列表
翻译:2024 年 9 月 3 日 Android 15 已发布至 AOSP
Android 15 新功能和 API 详解:Private Space/私密空间功能简介
Android 15 新功能和 API 详解:录屏检测,addScreenRecordingCallback
Android 15 新功能和 API 详解:应用程序启动信息,ApplicationStartInfo
Android 15 新功能和 API 详解:支持 16 KB 页面大小
Android 15 新功能和 API 详解:更精确的 Intent 解析,UriRelativeFilterGroup 和 UriRelativeFilter