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

谁都会走 提交于 2019-11-30 03:08:13

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

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.

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.

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
    }
    

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!