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

Android Studio构建报错:Manifest合并失败与ScrollView未声明问题

Android Manifest错误与布局代码放置问题解决方案

第一步:修正AndroidManifest.xml文件

  • 打开你的AndroidManifest.xml,彻底删除所有<ScrollView>、<LinearLayout>这类布局控件代码。Manifest是用来配置应用核心信息的(比如权限、页面声明),绝对不能放布局内容。
  • 确保Manifest结构符合标准示例:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="你的应用包名">

    <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.你的应用主题">
        <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>

第二步:解决Manifest合并冲突

删掉Manifest里的布局代码后,ScrollView@package属性冲突的问题会自动消失——这个冲突完全是因为你错误地把布局控件写到了Manifest里,和material库的配置内容冲突导致的。

第三步:把布局代码放到正确位置

  • 打开res/layout/下的布局文件(比如activity_main.xml),把之前误写的布局代码移到这里。示例结构:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!-- 这里添加你的其他控件,比如TextView、Button等 -->
    </LinearLayout>
</ScrollView>

第四步:清理并重构项目

  • 点击Android Studio顶部菜单栏的Build -> Clean Project,接着点Rebuild Project,清理缓存后重新构建项目。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 01:45:27