uses-sdk element cannot have a “tools:node” attrib

2020-02-20 07:44发布

问题:

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.

回答1:

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" .....
.../>


回答2:

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.



回答3:

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.



回答4:

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
    }
    


回答5:

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