1

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
}
spurgeon
  • 1,082
  • 11
  • 34
  • `Found versions 24.0.0`... Where is that version in your `build.gradle`? Please show the whole thing, including the `...` piece you removed. – OneCricketeer Mar 04 '17 at 18:54
  • @cricket_007 I added the full `build.gradle` file. There are no explicit dependencies on support-v4 version 24. – spurgeon Mar 05 '17 at 14:54
  • Even in `compile project` build.gradle file? – OneCricketeer Mar 05 '17 at 14:58
  • Also, you don't need `compile files('libs/`... That's what `compile fileTree` already does – OneCricketeer Mar 05 '17 at 14:59
  • @cricket_007 No dependencies on v24 in `compile project` build.gradle file. I have `compile 'com.android.support:support-v4:22.0.0'` in that project. Again, if I remove `com.google.android.gms:play-services-analytics:9.6.1` and `com.google.android.gms:play-services-ads:9.6.1`, this error message goes away. Is there some google play services dependency that's passed on to my project? – spurgeon Mar 05 '17 at 15:10
  • I know maps depends on the support library, not sure about those others... You should be able to run this http://stackoverflow.com/a/35235229/2308683 – OneCricketeer Mar 05 '17 at 16:44
  • 1
    Are you able to upgrade the compileSdk, buildToolsVersion, gradle plugin, Google Play Services, Firebase, and Gradle itself to all the latest versions? If you do this, your existing code should be fine (depending on any deprecated methods) – OneCricketeer Mar 07 '17 at 07:54
  • 1
    @cricket_007 I've resisted this so far because of waiting for one dependency I have (Glide) to work well with API 23 and above. But yes, moving everything to API 25 fixes this issue. – spurgeon Mar 07 '17 at 16:38
  • Gotcha. I think Picasso or Volley's ImageLoader should be fine substitutes for Glide, though I did read on android's site they recommend Glide – OneCricketeer Mar 07 '17 at 17:00
  • 1
    I'm just biting the bullet and updating to API 25. Thanks for your help. – spurgeon Mar 08 '17 at 15:03

0 Answers0