简体   繁体   中英

Adding glide dependencies messed appcompat

I added

implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'

so now I have

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.ofir.gamesuggestion"
        minSdkVersion 21
        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:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.android.gms:play-services-location:11.8.0'
    compile 'com.google.android.gms:play-services-places:11.8.0'
    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'
    implementation 'com.github.bumptech.glide:glide:4.4.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'

    }

    apply plugin: 'com.google.gms.google-services'

with android studio complaining.

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

I am not sure what to do with this as my understanding is that glide should not interfere with appcompt

In Gradle library support version mismatching with your project versions. Try with glide 3.7.0 instead.

Unfortunately when you get into the support libraries you hit all sorts of issues.

You can set transitive=false to make sure you don't bring down Glide dependencies and see if that fixes your issues.

Otherwise you can make sure you that you control the version all the way through.

So start by making sure you are using a gradle version that works for your needs as late of version as possible obviously.

Then you want to add in the google maven repo if you are building for 26 or later.

allprojects {
repositories {
    jcenter()
    maven(){ url "https://maven.google.com" } //as of 26 must include for google dependencies
    }
}

If you have conflicting gms VERSIONs which is common, simply add

  <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"
               tools:replace="android:value" />

into your Application tag, exactly the way I pasted above. there is not pseduo or replace values, just use exactly as pasted.

Next I typically define my versions at the top of my build file.

def gmsVersion = '11.2.2'
def googleSupportVersion = '-v7:'
def googleDesignVersion = '26.1.0'
def googleBuildTools = "26.0.1"
def firebaseVersion = "11.2.2"

These are a bit outdated as this project is a few months old now, but you can do latest.

Then i reference all my supports and push like:

   // [START google support]
compile 'com.android.support:cardview' + googleSupportVersion + googleDesignVersion
compile 'com.android.support:appcompat' + googleSupportVersion + googleDesignVersion
compile 'com.android.support:recyclerview' + googleSupportVersion + googleDesignVersion
compile 'com.android.support:design:' + googleDesignVersion
compile 'com.android.support:gridlayout'+ googleSupportVersion + googleDesignVersion
compile 'com.android.support:support-v4:' + googleDesignVersion
compile 'com.android.support.constraint:constraint-layout:1.0.2'
// [END   google support]

// [START gms_compile]
compile 'com.google.android.gms:play-services-base:11.2.2'
// [END   gms_compile]


// [START firebase]
compile 'com.google.firebase:firebase-core:' + firebaseVersion
compile 'com.google.android.gms:play-services-base:' + firebaseVersion
compile 'com.google.firebase:firebase-messaging:' + firebaseVersion
compile 'com.google.firebase:firebase-appindexing:' + firebaseVersion
// [END   firebase]

Also if you need to exclude one because of mismatch issues, you can do:

// Recommended
compile('com.philliphsu:bottomsheetpickers:2.4.1') {
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'design'
    exclude group: 'com.android.support', module: 'gridlayout-v7'
}

then for Glide I use

  compile 'com.github.bumptech.glide:glide:3.7.0'

If you are going to use the newer version of Glide which is fine, but if you are then you need to make sure you override or match or exclude all it's transitive dependencies.

Also pull out your gradle window and run Android Dependencies to see the cycle of what pulls in what dependencies, it will help you find out what versions are being pulled down.

Don't take the above versions as literal, adjust for your project needs, but make sure they are consistent across.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM