3
votes

Before I ask I want to state that I searched through a lot of similar threads but none of them worked.

I was debugging my app and for some reason when I cleaned and rebuilded my project I got the error: Manifest merger failed with multiple errors, see logs

In my gradle console I checked and got this:

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

Error:Missing 'name' key attribute on element activity at AndroidManifest.xml:6:5-44:16

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

Error: Validation failed, exiting

Here is my manifest:

<?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>

And the 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'
}

P.S I'm running version 2.3 and updated the tools as you see...! Thank you in advance everyone!

2
You can't nest activities inside activities and your first activity is missing the android:name attribute. - Titus
Well in a way you are right but with the previously releases it worked...don't know why...anyway robert's solution worked! - Chris Vera
Open application manifest(AndroidManifest.xml), click on the "Merged Manifest" tab next to the "Text" tab of the manifest file. You can view the error in the right column, try to solve the error and build again it will solve this error. For error: readyandroid.wordpress.com/… For more check: readyandroid.wordpress.com - Ready Android

2 Answers

9
votes

For me its was because I had declared the same meta tag twice in the manifest , Look if u have declared something twice .

1
votes

Instead of activity put application and put all activities inside it like this:

<?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>