After updating to Android Studio 2.3 today, I get an error regarding a support v4 jar version conflict, whereas I did not get it with Android Studio 2.2.
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 24.0.0, 22.2.0. Examples include com.android.support:support-v4:24.0.0 and com.android.support:recyclerview-v7:22.2.
Here's my gradle file:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.my.app"
minSdkVersion 17
targetSdkVersion 22
versionCode 12
versionName "2.1"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
// we want to split the output apks across architectures
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a', 'mips', 'armeabi'
universalApk false
}
}
// Set the versionCode for each architecture (armeabi-v7a, x86, etc) to be unique. When defaultConfig.versionCode is updated, these generated codes will be updated accordingly/automatically, so we shouldn't need to change this code.
applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) * 1000000 + android.defaultConfig.versionCode
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.caverock:androidsvg:1.2.1'
compile 'com.drewnoakes:metadata-extractor:2.8.1'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-ads:9.6.1'
compile 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.5.2'
compile files('libs/[third party library1].jar')
compile files('libs/[third party library2].jar')
compile project(':[third party project]')
compile files('libs/[third party library3].jar')
}
apply plugin: 'com.google.gms.google-services
If I remove com.google.android.gms:play-services-analytics:9.6.1
and com.google.android.gms:play-services-ads:9.6.1
, then I don't get this error, but my project also doesn't build because I need ads and analytics.
Does anyone know why this happens and how to fix? Is it possible that this problem existed before my 2.3 update, but 2.2 didn't report the issue?
EDITED (2017-03-05)
Added full build.gradle
file above
I can reproduce this error with the following reduced build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "sharpened.com.testgoogleplay"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-ads:9.6.1'
}
with Project build file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}