-1

Hello I am having a problem with my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.dell"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    implementation 'com.google.firebase:firebase-firestore:12.0.1'
    implementation 'com.firebaseui:firebase-ui-firestore:3.3.0'
    implementation 'hanks.xyz:htextview-library:0.1.5'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

Android Studio gives me this warning:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.0, 26.1.0. Examples include com.android.support:recyclerview-v7:27.1.0 and com.android.support:animated-vector-drawable:26.1.0

Can somebody please help me? I don't know what to do. I tried even making it v 27. I even deleted it, but it still didn't solve my problem.

I am also seeing this error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

ora
  • 79
  • 9

1 Answers1

2

Android Studio warning

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.0, 26.1.0. Examples include com.android.support:recyclerview-v7:27.1.0 and com.android.support:animated-vector-drawable:26.1.0

Problem

One of your dependencies (com.firebaseui:firebase-ui-firestore:3.3.0) has a transitive dependency on com.android.support:recyclerview-v7:27.1.0. Meanwhile, the support libraries that you manually declare in your build file use version 26.1.0.

Solution

Update compileSdkVersion and targetSdkVersion to 27 and your support libraries to 27.1.1

android {
    compileSdkVersion 27
    defaultConfig {
        targetSdkVersion 27
        ...
    }
    ...
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    ...
}

Tip (optional)

Since com.android.support:design has transitive dependencies on com.android.support:appcompat-v7 and com.android.support:support-v4, you do not have to manually declare the appcompat-v7 or support-v4 dependencies if you declare the design dependency.

  • @ora This question may help: https://stackoverflow.com/questions/47079113/android-studio-3-0-execution-failed-for-task-unable-to-merge-dex –  Apr 13 '18 at 07:46
  • let me try I will let you know – ora Apr 13 '18 at 07:58
  • It seems that one of the libraries you added uses a newer version of the recyclerview. Try updating your `compileSdkVersion` to 27, and all of your support library dependencies to 27.1.1. –  Apr 13 '18 at 08:22
  • I will try now and let you know – ora Apr 13 '18 at 08:28
  • Also, you can remove the `appcompat-v7` and `support-v4` support library dependencies since the `design` library depends on those libraries (called transitive dependencies) –  Apr 13 '18 at 08:31
  • should I remove them both? – ora Apr 13 '18 at 08:40
  • You can remove both. I edited my post with more info. I'm glad you got it working! –  Apr 14 '18 at 04:27