Android Support Repo 46.0.0 with Android Studio 2.3

AndroidAndroid StudioAndroid Support-Library

Android Problem Overview


I updated today my support repository to 46.0.0 as the Android Studio notification popped up.

I go the error below :

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

I updated all my dependencies to use Revision 26.0.0 Alpha 1 from 25.3.0, but it turns out I need to bump the compileSdk from 25 to 26. You can't do that if you have AS 2.3, you need to get the unstable alpha/beta version from canary.

This link shows the changes: https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0-alpha1

And concerning migrating to the new android O, that's the link: https://developer.android.com/preview/migration.html

It seems using AS stable version will not work with new repository.

How can I go back to the Android Studio Repository Version 45 instead of the new 46?

** Update: The merged manifest shows one of the generated library manifest contains

<meta-data
        android:name="android.support.VERSION"
        android:value="26.0.0-alpha1" />

But since it's a generated file editing is useless, that's why for now I'd stick to rev 45 until the new AS is in stable build

Android Solutions


Solution 1 - Android

What's the problem

Some libraries depend on version "X or newer" of Android support libraries so Gradle dependency resolution grabs whatever is the newest available ignoring you actually have a precise version specified in your dependencies block.

This is not what you want. You want all support libraries with same version and major version has to match compile SDK version.

What's the solution

Fortunately you can force a specific support library version.

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') {
            // Skip multidex because it follows a different versioning pattern.
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

Of course replace the version with whatever it is you're using.

Version values for support libraries in dependecies block are now irrelevant.

If you have doubts

This is a well documented method and it's working.

What can you do to help

Find the libraries which depend on a range of support library versions

gradlew dependencies --configuration compile -p <module name> | grep ,

and let the authors of said libraries know they should transitively depend on the oldest support libs their library can do with.

This aims to avoid the issue altogether.

Solution 2 - Android

Step 1

To escape Gradle checking for incompatible com.android.support versions a quick fix is to add following code in app module build.gradle.

dependencies {
    //noinspection GradleCompatible
}

This is a temporary fix that doesn't solve the underlying problems! It helped to continue develop your app with minimal modifications.

Step 2

Add this to the main manifest file AndroidManifest.xml.

<meta-data
    tools:replace="android:value"
    android:name="android.support.VERSION"
    android:value="25.3.1" />

This entry will be removed when one of the next updates of the support repository is available.

Step 3

Add the following code at the end of app module build.gradle file:

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

NB: It is recommended to make sure your Gradle libraries are updated and compatible to avoid runtime errors.

Solution 3 - Android

Their is a solution to fix it out:

  1. Move to Project explorer view
  2. Reach to bottom their is External Libraries
  3. See which library is using 26.0.0-alpha6
  4. Now write this in app.gradle on the basis of library in Step 3

Ex. in my case:

configurations.all {
    resolutionStrategy.force 'com.android.support:appcompat-v7:25.3.0'
    resolutionStrategy.force 'com.android.support:support-v13:25.3.0'
}

This will force project to use mentioned library.

Solution 4 - Android

I think the best solution is to just revert the Android Support Library to version 45.

To do this, open this link (change version to whatever suits your needs)

https://dl-ssl.google.com/android/repository/android_m2repository_r45.zip

When downloaded, unzip and copy m2repository to android-sdk-root-folder\extras\android. Make sure to delete the existing m2repository prior to unzipping to avoid problems.

Solution 5 - Android

This is a temporary fix that doesn't solve the underlying problems! It helped me continuing developing software with minimal modifications. Just add this to the main manifest:

<meta-data
    tools:replace="android:value"
    android:name="android.support.VERSION"
    android:value="25.3.0" />

This entry can hopefully be removed again with one of the next updates of the support repository.

SOLUTION: The marked solution worked for me by adding the following to 4 of my 10 build.gradle files:

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

Solution 6 - Android

just do this that's all :-

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

here v7:25.3.1 is my current version you just put urs.

in app gradle file

Solution 7 - Android

to me the problem was that the versions weren't the same in here

implementation 'com.android.support:appcompat-v7:**26.0.0-beta1**'
implementation 'com.android.support:support-v4:**26.0.0-beta1**'
implementation 'com.android.support:design:**26.0.0-beta1**'

and the card view was

compile 'com.android.support:cardview-v7:26.1.0'

so i changed the version libraries to..

implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'

hope this help, good luck

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionusernotnullView Question on Stackoverflow
Solution 1 - AndroidEugen PechanecView Answer on Stackoverflow
Solution 2 - AndroidHamza RashidView Answer on Stackoverflow
Solution 3 - AndroidRajesh TiwariView Answer on Stackoverflow
Solution 4 - AndroidZoran PView Answer on Stackoverflow
Solution 5 - AndroidLudgerView Answer on Stackoverflow
Solution 6 - AndroidAditya KumarView Answer on Stackoverflow
Solution 7 - AndroidAli MasarraView Answer on Stackoverflow