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

Android Studio初学者AndroidManifest.xml资源链接失败报错求助

报错根因

Android resource linking failed、unexpected element found报错来自清单文件语法错误:

  1. 文件开头存在两个重复的<manifest>根标签,Android清单文件仅允许一个顶层根节点,重复声明根节点属于非法语法
  2. 文件末尾缺失</manifest>根节点闭合标签
  3. 手动添加的tools:ignore="WrongManifestParent"属于无效兜底规则,没有解决根本问题
修复方案

直接按以下步骤修改AndroidManifest.xml:

  • 删除开头单独占行的多余标签:<manifest xmlns:tools="http://schemas.android.com/tools">
  • 将xmlns:tools命名空间声明合并到保留的唯一<manifest>标签中
  • 在文件最末尾补上缺失的</manifest>闭合标签
  • 清理项目后重新构建即可消除报错
修复后可直接使用的完整清单代码
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.MyPlace">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.TollGate">
        <activity
            android:name=".PlaceListActivity"
            android:exported="false" />
        <activity
            android:name=".AddPlacesActivity"
            android:exported="false" />
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
后续操作

替换完文件内容后,在Android Studio顶部菜单栏依次执行:

  1. 点击Build > Clean Project等待清理完成
  2. 点击Build > Rebuild Project重新构建项目
    构建完成后报错会自动消失。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 16:01:08