error: unexpected element <library> found in <manifest>原来是这回事啊

在新建的Android项目中遇到运行错误,通过逐个排除依赖的方式找到了问题根源:一个第三方库(com.microsoft.projectoxford:vision:1.0.374)移动导致依赖失败。注释掉该库后,问题得到解决。

最近新建一个项目,运行发现有错误,一时找不到方向,然后,就一个个依赖试过,哈~发现问题多可爱
问题:
在这里插入图片描述
在这里插入图片描述

Android resource linking failed
F:\XXX\app\build\intermediates\packaged_manifests\debug\AndroidManifest.xml:24: 
error: unexpected element <library> found in <manifest>.

这个问题是由于依赖第三方中,有个库项目发生了移动,依赖不到的情况,如果找不到,那就一个个注释排除,我这边出现的是下面这个

implementation 'com.microsoft.projectoxford:vision:1.0.374'

暂且注释掉就好了

D:/software/Gradle/wrapper/dists/gradle-8.4-all/caches/transforms-3/1c7ee2effc4702b7612f760440e420dd/transformed/jetified-databinding-ktx-8.3.2-api.jar!/META-INF/databindingKtx_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. D:\wordCode\HiAppProject\HiApp\build\intermediates\packaged_manifests\envBetaDebug\AndroidManifest.xml:347: warn: unexpected element <intent-downloadFilter> found in <manifest><application><activity>. D:\wordCode\HiAppProject\HiApp\build\intermediates\packaged_manifests\envBetaDebug\AndroidManifest.xml:679: warn: unexpected element <state> found in <manifest><application><receiver><intent-filter>. D:\wordCode\HiAppProject\HiApp\build\intermediates\packaged_manifests\envBetaDebug\AndroidManifest.xml:743: warn: unexpected element <state> found in <manifest><application><receiver><intent-filter>. D:\wordCode\HiAppProject\HiApp\build\intermediates\packaged_manifests\envBetaDebug\AndroidManifest.xml:1344: warn: unexpected element <state> found in <manifest><application><receiver><intent-filter>. D:\wordCode\HiAppProject\HiApp\build\intermediates\packaged_manifests\envBetaDebug\AndroidManifest.xml:1359: warn: unexpected element <state> found in <manifest><application><receiver><intent-filter>. warn: removing resource com.huawei.appmarket:plurals/agguard_find_n_risk_app without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_recent_scan without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_recent_scan_title_all_apps without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_recent_scan_title_has_virus without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_safety_report_chart_processed without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_scan_item_unused_apps_tips_more without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_sync_fa_unsafe without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_tab_scan_unsafe_bottom_tip without required default value. warn: removing resource com.huawei.appmarket:plurals/agguard_unknown_app_card_content_more without required default value. warn: removing resource com.huawei.appmarket:plurals/appcomment_accessibility_disliked without required default value. warn: removing resource com.huawei.appmarket:plurals/appcomment_accessibility_like_zero without required default value. warn: removing resource com.huawei.appmarket:plurals/appcomment_accessibility_liked without required default value. warn: removing resource com.huawei.appmarket:plurals/appzone_comment_count without required default value. warn: removing resource com.huawei.appmarket:plurals/cancel_ignore_desc without required default value. warn: removing resource com.huawei.appmarket:plurals/detail_comment_commented_people without required default value. warn: removing resource com.huawei.appmarket:plurals/downloadedreport_app_limited_ex without required default value. warn: removing resource com.huawei.appmarket:plurals/downloadedreport_awardtype_point_ex without required default value. warn: removing resource com.huawei.appmarket:plurals/forum_cards_sort_title without required default value. warn: removing resource com.huawei.appmarket:plurals/image_selected_count_title without required default value. warn: removing resource com.huawei.appmarket:plurals/media_selected_count without required default value. warn: removing resource com.huawei.appmarket:plurals/pics_num_tips without required default value. warn: removing resource com.huawei.appmarket:plurals/server_upgrades_prompt_minute_format without required default value. warn: removing resource com.huawei.appmarket:plurals/update_notify_title_ex_new without required default value. warn: removing resource com.huawei.appmarket:plurals/video_num_tips without required default value. warn: removing resource com.huawei.appmarket:plurals/video_selected_count_title without required default value. warn: removing resource com.huawei.appmarket:plurals/weibo_share_word without required default value. warn: removing resource com.huawei.appmarket:string/about_fans_qq_group without required default value. warn: removing resource com.huawei.appmarket:string/about_weixin_account without required default value. warn: removing resource com.huawei.appmarket:string/about_xinweibo_account without required default value. warn: removing resource com.huawei.appmarket:string/agguard_add_security_control_explanation without required default value. warn: removing resource com.huawei.appmarket:string/agguard_app_intercept_description without required default value. 讲解报错
07-01
### 三级标题:AndroidManifest.xml 中注册 Service 时出现的错误:unexpected element `<service>` found in `<manifest>` 在 Android 应用开发过程中,如果在 `AndroidManifest.xml` 文件中注册 `<service>` 时出现 `error: unexpected element <service> found in <manifest>` 错误,通常是由于 `<service>` 标签的位置或结构不符合 XML 规范。 `AndroidManifest.xml` 文件的根元素 `<manifest>` 下只能包含特定的子元素,例如 `<application>`、`<uses-permission>`、`<permission>` 等。而 `<service>` 标签必须位于 `<application>` 标签内部,不能直接作为 `<manifest>` 的子元素。若将 `<service>` 直接写在 `<manifest>` 下,会导致 AAPTAndroid Asset Packaging Tool)解析失败,并抛出该异常[^1]。 正确的 `<service>` 注册方式如下: ```xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app"> <application android:allowBackup="true" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <service android:name=".MyService" android:enabled="true" android:exported="false" /> </application> </manifest> ``` 上述代码中,`<service>` 被正确地嵌套在 `<application>` 标签内部,确保 AAPT 能够正确解析并生成资源表[^1]。 此外,如果项目使用了 Gradle 插件版本 3.4.x 或更早版本,并且升级了 Android Studio 至 4.x 版本,可能会遇到类似的 XML 解析问题。建议将 Gradle 插件升级至 4.0.1 或更高版本以兼容新版本工具链[^4]。 --- ### 三级标题:相关问题
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值