添加滑动依赖项混乱了appcompat

时间:2018-01-05 16:07:10

标签: android gradle android-glide

我添加了

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

现在我有了

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'

与android studio抱怨。

所有com.android.support库必须使用完全相同的版本规范。

我不知道该怎么做,因为我的理解是滑行不应该干扰appcompt

2 个答案:

答案 0 :(得分:1)

Gradle库支持版本与项目版本不匹配。尝试使用滑翔3.7.0。

答案 1 :(得分:1)

不幸的是,当你进入支持库时,你遇到了各种各样的问题。

您可以设置transitive = false,以确保不会降低Glide依赖关系,看看是否能解决您的问题。

否则,您可以确保自己一直控制版本。

首先,请确保您使用的gradle版本尽可能地满足您的需求。

如果您要为26或更高版本构建,则需要添加google maven repo。

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

如果您有常见的冲突gms VERSION,只需添加

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

进入您的Application标签,完全按照我上面粘贴的方式。没有pseduo或替换值,只需使用完全粘贴。

接下来,我通常会在构建文件的顶部定义我的版本。

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

这个项目有点过时,因为这个项目现在已经有几个月了,但你可以做最新的。

然后我引用我的所有支持并按下:

   // [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]

此外,如果由于不匹配问题需要排除一个,您可以执行以下操作:

// 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'
}

然后对于Glide我使用

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

如果您打算使用较新版本的Glide,那么您可以确保覆盖或匹配或排除其所有传递依赖项。

同时拉出你的gradle窗口并运行Android Dependencies以查看拉入什么依赖项的循环,它将帮助你找出正在下载的版本。

不要将上述版本视为文字,根据您的项目需求进行调整,但要确保它们一致。