Android Studio - Gradle Manifest Merging Failed

2019-03-12 14:45发布

I am building a demo app using actionbar sherlock in android studio and i was facing problem , mentioned in following link :- Previous Problem

now after following the replies posted on above link i did some changes and now i am facing this

Gradle: Execution failed for task ':SherlockTest:processDebugManifest'.
> Manifest merging failed. See console for more info.

my application manifest file is :-

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.sherlocktest"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.sherlocktest.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

and actionbar sherlock manifest file is :-

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          android:versionCode="440"
          android:versionName="4.4.0"
          package="com.actionbarsherlock">

  <uses-sdk
          android:minSdkVersion="10"
          android:targetSdkVersion="16"/>

  <application/>

</manifest>

i am not able to figure out what is the problem here, please help

4条回答
冷血范
2楼-- · 2019-03-12 15:19

Make sure that in all your build.gradle scripts the minSdkVersion and targetSdkVersion correspond to those you have in your manifests:

android {
    defaultConfig { 
       minSdkVersion 10
       targetSdkVersion 16
    }
}

This worked for me, I hope it does the trick for you, cheers.

查看更多
乱世女痞
3楼-- · 2019-03-12 15:24

For what I can see, if you have a multi-module project with Android Studio and gradle, the IDE try to merge manifest files from every module into a Main manifest.

If you have a module A and a module B, and in the A manifest you declare some activity from B module, gradle will enconter a issue when merging.

Try removing cross-module reference in manifest files.

查看更多
Ridiculous、
4楼-- · 2019-03-12 15:26

That works for me.
My library project AndroidManifest.xml miss a application element
add one will fix it.

<application
    android:allowBackup="true"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
</application>

I use gradle clean projectName --info get the error information, and solve it.

查看更多
【Aperson】
5楼-- · 2019-03-12 15:36

That worked for me when adding the Google Play Services

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 16
    }
}
查看更多
登录 后发表回答