0

Edit : i also this post

All com.android.support libraries must use the exact same version specification

i upgrade downgrade multiple version of android support libraries . but i am constantly getting this error . specially on these lines

compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'

i clean and rebuild multiple times , but that is not solution

there is no specifically any solution which i got except changing library version .

this is app gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.2'

    defaultConfig {
        applicationId "com.codepath.the_town_kitchen"
        minSdkVersion 27
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    signingConfigs {
        debug {
            storeFile file("keystore/debug.keystore")
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories { mavenCentral() }

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')


    //compile 'com.android.support:appcompat-v7:21.0.3'
    //compile 'com.android.support:support-v4:21.0.3'
    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.loopj.android:android-async-http:1.4.6'
    compile 'com.google.android.gms:play-services:6.5.87'
    // ActiveAndroid for simple persistence with an ORM
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.github.johnkil.android-robototextview:robototextview:2.3.0'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    //compile 'com.stripe:stripe-android:+'
    // compile 'com.android.support:cardview-v7:21.0.2'
    compile 'com.android.support:recyclerview-v7:27.0.2'
    compile 'com.android.support:cardview-v7:27.0.2'

    //compile 'com.android.support:design:26.0.2'

    compile 'com.makeramen:roundedimageview:1.5.0'
    //compile 'com.stripe:stripe-android:2.0.2'
}

is there any particular by whoch android studio can automatically set version of all existing libraries ? i need some suggestions

Neeraj Verma
  • 2,174
  • 6
  • 30
  • 51

2 Answers2

4

is there any particular by whoch android studio can automatically set version of all existing libraries ?

Yes, android studio will automatically set version of all existing libraries by this code. Put this at the end of your app module in build.gradle.

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            details.useVersion '27.0.2'
        }
    }
}

This will find all support dependencies and force their versions to be 27.0.2. This will solve your problem.

Jaydip Kalkani
  • 2,493
  • 6
  • 24
  • 56
  • Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex ............. this error started to come , thats very irritating issue – Neeraj Verma Mar 04 '18 at 08:54
  • first of all try to clean your project and rebuilt it. Let me know if it works or not.@NeerajVerma – Jaydip Kalkani Mar 04 '18 at 09:24
  • No still not working , can you share screen wid me and help me out when u are available – Neeraj Verma Mar 04 '18 at 13:02
  • Yes, i can. i am not too good in it but i can try my best to solve your problem. i am not free now...so if you don't mind send me request on my fb ac... i will msg you when i will become free. My fb ac:- https://www.facebook.com/kalkani.jaydip.1 – Jaydip Kalkani Mar 04 '18 at 13:09
  • This causes the following error: **Caused by: java.lang.IllegalStateException: Unexpected inputs: ImmutableJarInput{name=com.android.support:support-v13:27.1.1, file=/app/build/intermediates/transforms/desugar/debug/35.jar, contentTypes=CLASSES, scopes=EXTERNAL_LIBRARIES, status=REMOVED}** – IgorGanapolsky Apr 23 '18 at 18:25
  • I think you are adding it at wrong location. Insert this code in app level build.gradle file at end. @IgorGanapolsky – Jaydip Kalkani Apr 24 '18 at 08:55
1

To avoid this you need to update your libs too.

Your libs like Picasso also contain 'com.android.support' library which need to be compatible with you app 'com.android.support' library, And I can see you used old versions of library which contain old version of 'com.android.support'.

You need to use libs that contain the compatible 'com.android.support' version, In your case it's 27.0.2

For example Picasso needed to upgrade to 2.5.2 instead.