0
votes

I using com.android.tools.build:gradle:3.1.0 and gradle build failed with error below.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:preDebugBuild'.

    Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0) and runtime (27.0.2) classpath. You should manually set the same version via DependencyResolution

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

enter image description here

3
Any solutions yet? - IntelliJ Amiya

3 Answers

0
votes

Upgrade your support library version to com.android.support:support-v4-27.0.2

0
votes

Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0) and runtime (27.0.2) classpath. You should manually set the same version via DependencyResolution

FYI

You should manually set the same version via DependencyResolution.

  • Use com.android.support same version. You can use 27.1.1.

DEMO

implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:design:27.1.1"

And upgrade below version from Module Level build.gradle.

compileSdkVersion 27
buildToolsVersion "27.0.3"

Note

You can Upgrade your gradle version.

com.android.tools.build:gradle:3.1.2
0
votes

The problem is happened because you have multiple conflicted dependencies of 'com.android.support:support-v4'. So, you need to use only one version of support-v4 by excluding all other support-v4 library inside of your dependencies.

You first need to check the dependencies tree by running the following command in your terminal inside your root project directory:

./gradlew app:dependencies

or use the following command if you're using Windows:

gradlew app:dependencies

app is your module name.

You will get the dependencies tree then. After that, check all libraries that using the support library. Exclude the support-v4 library from them. For example, if you have a dependency with support library something like this:

implementation 'com.package.libraryname:1.0.0'

then you need to exclude the support-v4 with this:

implementation ('com.package.libraryname:1.0.0') {    
    exclude group: 'com.android.support'
    exclude module: 'support-v4'
}

Add the same exclude line to all conflicted support-v4 library.