gpt4 book ai didi

android - 添加 glide 依赖项弄乱了 appcompat

转载 作者:行者123 更新时间:2023-12-03 04:59:54 25 4
gpt4 key购买 nike

我添加了

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 库必须使用完全相同的版本规范。

我不确定该怎么做,因为我的理解是 glide 不应该干扰 appcompt

最佳答案

不幸的是,当您进入支持库时,您会遇到各种问题。

您可以设置 transitive=false 以确保您不会关闭 Glide 依赖项并查看是否可以解决您的问题。

否则,您可以确保您始终控制版本。

因此,首先要确保您使用的 gradle 版本显然可以满足您的需求,并且版本越晚越好。

然后,如果您要为 26 或更高版本构建,则需要添加 google maven 存储库。

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

如果您有常见的 gms 版本冲突,只需添加
  <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"
tools:replace="android:value" />

进入您的应用程序标签,就像我上面粘贴的那样。没有伪或替换值,只需完全按照粘贴的方式使用。

接下来,我通常在构建文件的顶部定义我的版本。
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 以查看哪些依赖项的循环,它将帮助您找出哪些版本正在被拉下。

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

关于android - 添加 glide 依赖项弄乱了 appcompat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48117212/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com