114

After accepting to update the project to new version of gradle I get this error:

Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1) from [com.android.support:cardview-v7:26.0.0-alpha1] AndroidManifest.xml:24:9-38
    is also present at [com.android.support:design:25.3.1] AndroidManifest.xml:27:9-31 value=(25.3.1).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:22:5-24:41 to override.

How can I solve this problem? This is my app's build.gradle file:

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.sample.bookReader"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    ...
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:multidex:+'
    compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support:cardview-v7:26.0.0-alpha1'
    compile 'com.android.support:design:25+'
    compile 'com.jakewharton:butterknife:8.2.1'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'
    ...
}

And this is the project's build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://www.jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

How do I fix this error while maintaining the changes made by updating the gradle version?

Ícaro
  • 1,432
  • 3
  • 18
  • 36
tux-world
  • 2,680
  • 6
  • 24
  • 55

13 Answers13

214

Put this at the end of your app module build.gradle:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

Credit to Eugen Pechanec

Manohar
  • 22,116
  • 9
  • 108
  • 144
Vishal Dasadiya
  • 2,585
  • 1
  • 14
  • 11
  • 1
    Nice one, this is the solution that worked for me when building my nativescript app – ded Sep 08 '17 at 22:11
  • 7
    This did work for me as well, thanks @Vishal. Can you just explain what is happening in here :) – Ismail Iqbal Sep 12 '17 at 14:04
  • Please refer below link. https://developer.android.com/studio/build/manifest-merge.html – Vishal Dasadiya Sep 14 '17 at 08:43
  • 3
    Make sure to use the latest version of support library, which at the time of writing this is `details.useVersion '27.0.0'`. Otherwise you won't have the latest support features, like redundant view casting elimination. – Drew Szurko Nov 01 '17 at 02:34
  • 9
    Please add bit description about it. Its working but will it work for updated version and features – GS Nayma Nov 28 '17 at 11:19
  • Thank you for saving my day. – Parth Patel Jul 31 '18 at 10:31
  • 1
    If anyone else had the 'Cannot resolve Symbol DependencyResolveDetails' error, I fixed it by removing 'DependencyResolveDetails' (I read somewhere on StackOverflow about not needing it since its Groovy, so it can dynamically work it out) – knjk04 Feb 25 '19 at 09:28
  • @Vishal sir i have tried but got error again : Attribute meta-data#com.google.android.geo.API_KEY@value at AndroidManifest.xml:53:66-112 requires a placeholder substitution but no value for is provided.? – Kapil Soni May 23 '19 at 11:38
  • 1
    For those wondering what this piece of code does. It goes through each dependency, checks what packages each dependency is pulling at making sure that ones that require support libraries pull the correct version – kPieczonka Jun 21 '19 at 13:10
90

You are using multiple versions of the Android Support Libraries:

compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:design:25+'

Two are 26.0.0-alpha1, and one is using 25+.

Pick one concrete version and use it for all three of these. Since your compileSdkVersion is not O, use 25.3.1 for all three of these libraries, resulting in:

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • using `25.3.1` for support libraries or `buildToolsVersion`? for `buildToolsVersion` i get error `Package Unavailable` – tux-world Apr 07 '17 at 14:59
  • @tux-world: "using 25.3.1 for support libraries or buildToolsVersion?" -- for the support libraries. See my updated answer. – CommonsWare Apr 07 '17 at 15:04
  • 1
    i test that, but my problem don't resolve, which version must be on `compileSdkVersion` ? – tux-world Apr 07 '17 at 15:05
  • i get this message `All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.0.0-alpha1, 25.3.1. Examples include com.android.support:support-compat:26.0.0-alpha1 and com.android.support:animated-vector-drawable:25.3.1` – tux-world Apr 07 '17 at 15:07
  • 1
    @tux-world: Nothing in your `build.gradle` should be referring to `26.0.0-alpha1` anymore. Try cleaning your project (Build > Clean Project) and see if the problem goes away. If not, you are going to need to track down what is pulling in `com.android.support:support-compat:26.0.0-alpha1`, such as by running a Gradle dependency report. – CommonsWare Apr 07 '17 at 15:09
  • Thanks, i can find which library cause of problem – tux-world Apr 07 '17 at 16:33
  • That helped ! Thanks – akash89 Oct 19 '17 at 06:23
18

I changed all support library versions to 25.3.1 and worked like a charm:

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'

You also need to change compileSdkVersion and targetSdkVersion to 25:

compileSdkVersion 25
targetSdkVersion 25
Darush
  • 11,403
  • 9
  • 62
  • 60
10

You can find out what library depends on a wrong version of the support library and exclude it like this:

compile ('com.stripe:stripe-android:5.1.1') {
    exclude group: 'com.android.support'
  }

stripe-android in my case.

Ícaro
  • 1,432
  • 3
  • 18
  • 36
paynd
  • 813
  • 8
  • 16
6

I'm not using different versions of libraries and got the same error, it's happened after remove buildToolsVersion in AS RC 1, but adding tools:node="replace" did the trick, just add this into your manifest.xml inside <application ..../> block:

<meta-data 
 tools:node="replace"
 android:name="com.google.android.gms.version"
 android:value="@integer/google_play_services_version" />
  • 1
    are there any side-effects when doing this? Is it still working for you with the new Android Studio 3? – Sakiboy Oct 30 '17 at 02:20
5

It happen the same thing to me. See on Gradle -> Build Gradle -> and make sure that the compatibility matches in both compile "app compat" and "support design" lines, they should have the same version.

Then to be super sure, that it will launch with no problem, go to File -> Project Structure ->app and check on tab propertie the build Tools version, it should be the same as your support compile line, just in case i put the target SDK version as 25 as well on the tab Flavors.

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-
   core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    *compile 'com.android.support:appcompat-v7:25.3.1'*
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    *compile 'com.android.support:design:25.3.1'*
}

Thats what I did and worked. Good luck!

3
  • Update your support library to last version

  • Open Manifest File , and add it into Manifest File

  • <uses-sdk tools:overrideLibrary="android.support.v17.leanback"/>

  • And add for recyclerview in >> build.gradle Module app :

  • compile 'com.android.support:recyclerview-v7:25.3.1'

  • And click : Sync Now

Agilanbu
  • 2,747
  • 2
  • 28
  • 33
AmmAr Yasser
  • 321
  • 2
  • 17
3

I solve that with putting this at the end of my app module build.gradle:

    configurations.all {
     resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '26.0.0'
        }
    }
  }
}
Maryam Azhdari
  • 1,161
  • 11
  • 8
2

The answer are accepted but one thing you could also do is to define the libraries from your project structure. What you can do is :

  1. Comment all the libraries in which problem is coming
  2. Goto your project structure
  3. Add libraries from there and it'll sync automatically and the problem goes off.
  4. If problem persists try looking from the error log that what library is it demanding after following all the above 3 steps.

What happens is the predefined libraries as off now now I'm taking the appcompat:26.0.0-alpha1 it uses the older version of the things when you add something new and tries to resolve it with the old stuffs. When you add it from your project structure, it'll add the same thing but with the new stuffs to resolve it. Your problem would be resolved.

Alok
  • 8,452
  • 13
  • 55
  • 93
0

The error for me was:

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:percent:26.0.2] AndroidManifest.xml:25:13-35
    is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override.

The solution for me was in my project Gradle file I needed to bump my com.google.gms:google-services version.

I was using version 3.1.1:

classpath 'com.google.gms:google-services:3.1.1

And the error resolved after I bumped it to version 3.2.1:

classpath 'com.google.gms:google-services:3.2.1

I had just upgraded all my libraries to the latest including v27.1.1 of all the support libraries and v15.0.0 of all the Firebase libraries when I saw the error.

Lucy
  • 436
  • 5
  • 8
0

I have updated old android project for the Wear OS. I have got this error message while build the project:

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(26.0.2) from [com.android.support:percent:26.0.2] AndroidManifest.xml:25:13-35
is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value=(26.1.0).
Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override.

My build.gradle for Wear app contains these dependencies:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.support:wearable:2.4.0'
implementation 'com.google.android.gms:play-services-wearable:16.0.1'
compileOnly 'com.google.android.wearable:wearable:2.4.0'}

SOLUTION:

Adding implementation 'com.android.support:support-v4:28.0.0' into the dependencies solved my problem.

Kiryl Bielašeŭski
  • 2,663
  • 2
  • 28
  • 40
0

Try deleting the meta data and rebuild project.

Anga
  • 2,450
  • 2
  • 24
  • 30
-4

you try read link this

Error:Execution failed for task ‘:app:processDevDebugManifest’. Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.0) then usd VERSION 26.0.0

: https://medium.com/@PongPloyAppDev/error-execution-failed-for-task-app-processdevdebugmanifest-48576be751

enter image description here

Pong Petrung
  • 1,437
  • 17
  • 14