21

I've updated Android Studio last night to 0.9.0, buildToolsVersion to 21.1.0 and gradle to 0.14.0, after that I'm receiving this error

Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute

I've spent the last night looking for a solution, I found this:
<uses-sdk tools:node="replace" />

But unfortunately, added one more error!

Error:(10, 5) uses-sdk element cannot have a "tools:node" attribute
Error:(10, 5) Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute

Another solution I've read, to not use support-v4:21, for me I don't use it, since I'm using v13.

Hisham
  • 353
  • 1
  • 3
  • 12

5 Answers5

19

Solution:--

Add this line to uses-sdk tag like this:-

<uses-sdk
    tools:node="merge"   <----This line do the magic
    android:minSdkVersion="14"
    android:targetSdkVersion="19" />

And add the tools name space in manifest :-

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" .....
.../>
Kailash Dabhi
  • 3,473
  • 1
  • 29
  • 47
8

OK this is not the answer, but a temporary workaround.

According to the Gradle build tools release notes this problem was fixed in version 0.13.2 (2014/09/26)
However, seems to happen again in 0.14.0 (2014/10/31)

You can disable the manifest merger task in order to build your project for the time being.
Add the following in your build.gradle file

android.applicationVariants.all { variant ->
variant.processResources.manifestFile = file('src/main/AndroidManifest.xml')
variant.processManifest.enabled=false }

See this question for reference.

Community
  • 1
  • 1
Medo
  • 671
  • 4
  • 11
  • I updated the IDE / gradle build tools on my other desktop, sync / build works perfectly. I would appreciate any insight on the matter. – Medo Nov 03 '14 at 10:38
  • 1
    More insight: It appears that the ASNE library caused this issue, check out my comments at the [bug report](https://github.com/gorbin/ASNE/issues/46) – Medo Nov 06 '14 at 10:21
4

I ran into this after upgrading to Android Studio 1.0.0 rc4. I had previously been using so that I could make projects with lower min SDK versions than some of the libraries they depended on. Turns out, if you remove tools:replace and let the compiler error out again with the manifest merge conflict, it will provide you with a much better solution:

<uses-sdk tools:overrideLibrary="com.google.android.gms" />

At least, the Google Play Services library was what I was running into. Actually, you can list a whole bunch if you need to. Just comma-separate the package names. You may have to run the compiler a few times until it tells you every library that's causing problems.

Joel
  • 66
  • 2
3

My solution

  • I have removed all of the <uses-sdk tools:node="replace" /> From all of my manifest.xml files
  • In my base.gradle file(the one for the entire project I Added

    ext {
      compileSdkVersion = 19
      buildToolsVersion = "21"
      minSdkVersion = 10
      targetSdkVersion = 19
    }
    
  • In my modules I have this

    // all modules
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    // in an application module
    defaultConfig {
       applicationId "com.something"
       minSdkVersion rootProject.ext.minSdkVersion
       targetSdkVersion rootProject.ext.targetSdkVersion
       versionCode appVersionCode
       versionName appVersionName
    }
    
Elad Gelman
  • 1,182
  • 1
  • 13
  • 27
3

The problem has solved after updating the AS to v0.9.1 and Gradle to 0.14.1.

Thank you guys_

Update

The problem appears again!

Update 2

Here is a workaround to solve this problem:

  1. Open your project with Android Studio 0.8.14 / Gradle build tools 0.13.2
  2. Build your project.
  3. Switch back to Android Studio 0.9.1 / Gradle build tools 0.14.1
  4. gradlew assembleRelease will work now
Hisham
  • 353
  • 1
  • 3
  • 12
  • I have AS 0.9.2, Gradle 0.14.1, and error still there. – laph Nov 09 '14 at 09:38
  • Iaph a quick help, if you are using any external libraries (like in my case ASNE) make sure the manifest of these libraries do not have – Hisham Nov 09 '14 at 10:56