Manifest合并失败,出现多个错误,请查看日志(错误:执行任务“:app:processDebugManifest”失败)。

3

在提问之前,我想声明一下,我搜索了很多类似的帖子,但都没有解决我的问题。

我正在调试应用程序,但由于某种原因,当我清理并重新构建我的项目时,我出现了这个错误:Manifest merger failed with multiple errors, see logs

在我的gradle控制台中,我检查并得到了以下信息:

C:\Users\Chris\AndroidStudioProjects\WizardCounter2\app\src\main\AndroidManifest.xml:6:5-44:16

错误:在AndroidManifest.xml:6:5-44:16中的活动元素上缺少 'name' 关键属性

C:\Users\Chris\AndroidStudioProjects\WizardCounter2\app\src\main\AndroidManifest.xml

错误:验证失败,退出

以下是我的清单文件:

<?xml version="1.0" encoding="utf-8"?>

<activity
    android:allowBackup="true"
    android:icon="@drawable/counter_launch_icon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
   >

    <activity
        android:name=".HomeScreen"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".GameMenu"
        android:label="@string/title_activity_game_menu"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait"
        android:value="HomeScreen"/>
    <activity
        android:name=".PlayerSelection"
        android:label="@string/title_activity_player_selection"
        android:value="PlayerSelection"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        >
    </activity>

    <support-screens

        android:smallScreens="true"
        android:normalScreens="true" />
</activity>

build.gradle 文件如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.gameapp.android.wizardcounter"
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
}

附言:我正在运行2.3版本,并更新了工具,正如你所看到的...谢谢大家提前!


1
你不能在活动内嵌套另一个活动,且你的第一个活动缺少“android:name”属性。 - Titus
在某种程度上你是对的,但之前的版本它是可以工作的...不知道为什么...无论如何,Robert的解决方案起作用了! - Chris Vera
打开应用程序清单(AndroidManifest.xml),点击清单文件旁边的“合并清单”选项卡,而不是“文本”选项卡。您可以在右侧列中查看错误,尝试解决错误并重新构建即可解决此错误。 有关错误信息,请参见:https://readyandroid.wordpress.com/errorexecution-failed-for-task-appprocessdebugmanifest-manifest-merger-failed-with-multiple-errors-see-logs-android/ 更多信息请查看:https://readyandroid.wordpress.com/ - Ready Android
2个回答

8

对我来说,这是因为我在清单文件中声明了相同的元标签两次,检查一下是否有重复声明。


但是在重新构建后,它会自动添加回去。我无法修改清单文件。 - Shah Nilay
@Shrini Jaiswal 给你点赞。你节省了我的时间。谢谢。 - Sagar Aghara
@shanilay86 请尝试这个。那个答案更通用,可能会解决你的问题。 - Kathir

1

不要使用Activity,而是使用Application,并将所有的Activity放在其中,像这样:

<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@drawable/counter_launch_icon"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
>

<activity
    android:name=".HomeScreen"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name=".GameMenu"
    android:label="@string/title_activity_game_menu"
    android:theme="@style/AppTheme.NoActionBar"
    android:screenOrientation="portrait"
    android:value="HomeScreen"/>
<activity
    android:name=".PlayerSelection"
    android:label="@string/title_activity_player_selection"
    android:value="PlayerSelection"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar"
    >
</activity>

<support-screens

    android:smallScreens="true"
    android:normalScreens="true" />
</application>

有时候你会在清单文件的应用程序标签内重复多次使用同一个活动标签。尝试删除多余的活动标签。 - sudharsan chandrasekaran

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接