2

I have read the thread at All com.android.support libraries must use the exact same version specification and many other such threads but none of the answers have solved my problem.

Errors:-

1.) For implementation 'com.android.support:appcompat-v7:26.1.0'

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:26.1.0 less... (Ctrl+F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

2.) on building the project

Error: Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "freview1.com.freview"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 2
        versionName '2.2.1'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        //vectorDrawables.useSupportLibrary = true
        versionNameSuffix '-alpha'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
/*
ext {
    supportLibVersion = '26.1.0'  // variable that can be referenced to keep support libs consistent
}
*/

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:percent:26.1.0'
    implementation 'com.android.support:support-vector-drawable:26.1.0' // VectorDrawableCompat
    implementation 'com.android.support:animated-vector-drawable:26.1.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:16.0.3'
    implementation 'com.google.firebase:firebase-auth:16.0.3'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'com.squareup.picasso:picasso:2.5.2'
}    

apply plugin: 'com.google.gms.google-services'
Deepak
  • 33
  • 9

3 Answers3

0

if you want add an library to your project , best way is :

in android studio : (from toolbar) file \ Project Structure ... \ (from left window , under modules ) app \ Dependencies \ [use green plus]

for example if you want use compileSdkVersion 27 , your import code should be like this :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "your project"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:support-v4:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-vector-drawable:27.1.0'

    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.android.support.test.espresso:espresso-core:3.0.1'

}

It's work for me , and if you want use compileSdkVersion 28 , your import code should be like this :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "your project"
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '28.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'junit:junit:4.12'
    implementation 'com.android.support:support-v13:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.android.support:mediarouter-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:support-annotations:28.0.0'

}

It's work for me too . Many of these problems will disappear with the help of a new library and you will have more efficient classes.

I hope it's work for you .

This version can help you , I test it , it's working :

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
    implementation 'com.android.support:support-v4:26.0.0-beta1'
    implementation 'com.android.support:design:26.0.0-beta1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
    implementation 'com.android.support:gridlayout-v7:26.0.0-beta1'
    implementation 'com.android.support:recyclerview-v7:26.0.0-beta1'
    implementation 'com.android.support:cardview-v7:26.0.0-beta1'
}
A.Bahrami
  • 228
  • 3
  • 9
  • Thanks. I previously had compileSdkversion as 28 itself but I was trying to bring it down to 26 because my app isn't running on one of my friend's phone with Android 6.0 but runs on another friend's phone with the same Android 6.0. For now I'm ignoring this problem since both have same OSes so maybe the former friend's phone has some problem. – Deepak Sep 30 '18 at 14:04
  • I add v26-beta1 version , I test it one some Genymotion android device and worked for me . Please try it , I hope it work for you – A.Bahrami Sep 30 '18 at 15:29
0

Ok , I finally find your solution , Just add this Lines :

repositories {
    mavenCentral()
    maven { url "https://maven.google.com" }

}

for example :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "your app id"
        minSdkVersion 14
        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(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
    implementation 'com.android.support:gridlayout-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:cardview-v7:26.1.0'
}

repositories {
    mavenCentral()
    maven { url "https://maven.google.com" }
}
A.Bahrami
  • 228
  • 3
  • 9
0

It's mostly happens when you use Libraries that uses old version of AppCompat. It happens to me all the time when I use switchButton library. for last 6 month it didn't impact anything, it's just a false alarm.

SinaMN75
  • 6,742
  • 5
  • 28
  • 56