添加Glide依赖时出现问题

3
我用Java在Android上编写了一个程序,当我添加Glide依赖项时, implementation 'com.github.bumptech.glide:glide:4.9.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' 我的Android Studio开始给我报错: "ERROR: Failed to resolve: support-fragment Affected Modules: app ERROR: Failed to resolve: animated-vector-drawable Affected Modules: app" 这是我的app build.gradle文件,显示了错误。

上周我寻找了任何类似的答案并尝试了所有方法,但我无法解决这个问题。当我删除Glide依赖项时,一切恢复正常。
这是我的应用模块build.gradle文件:
    apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.mohammad.kahgle"
    minSdkVersion 21
    targetSdkVersion 28
    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:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.github.armcha:ElasticView:0.1.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.nightonke:boommenu:2.1.1'
implementation 'com.ramotion.foldingcell:folding-cell:1.2.2'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation "com.android.support:support-core-utils:28.0.0"
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'

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

你能发布你的应用程序模块 build.gradle 吗? - dardardardar
你已经有了 defaultConfig { vectorDrawables.useSupportLibrary = true } 吗? - ADM
@dardardardar 我已经将其添加到问题中。 - mohammad
@ADM 是的,没有改变。 - mohammad
尝试在Glide依赖项中使用kapt而不是annotationProcessor - Hello World
@HelloWorld 谢谢,但它也不起作用。 - mohammad
6个回答

3
我有这个问题。如果你不使用Glide的矢量图动画,可以使用以下代码来排除无用依赖:
implementation ("com.github.bumptech.glide:glide:4.9.0"){
    exclude group: 'androidx.vectordrawable', module: 'vectordrawable-animated'
}

愉快编码 :)


2

使用以下库解决此问题,最低SDK版本为21,目标SDK版本为29:

将以下内容添加到依赖项中:

implementation 'androidx.fragment:fragment:1.2.0-rc04'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'

将Glide版本降级至4.8.0。

implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'

1

将以下内容添加到您的build.gradle文件中。详情请参见Glide的下载部分。

repositories {
  mavenCentral()
  google()
}

你把这个放在 build.gradle 文件的哪里了?我没看到。 - Jakir Hossain
2
是的,我以前做过,但网络上的解决方案对我不起作用。 - mohammad

0
在您的应用程序模块中启用vectorDrawables useSupportLibrary。
android {
    compileSdkVersion 27
    defaultConfig {
        ....
        vectorDrawables.useSupportLibrary = true
    }
}

然后将其添加到依赖项中

dependencies {
    implementation 'com.android.support:support-vector-drawable:27.1.1'
}

2
我做了这个,也得到了这个错误: 错误:无法解析:support-vector-drawable 受影响的模块:app - mohammad

0
解决方案是删除~/.gradle内的缓存文件夹并重新下载依赖项。
添加:
 implementation 'androidx.fragment:fragment:1.2.0-alpha04' 
 implementation 'androidx.vectordrawable:vectordrawable:1.1.0' 
 implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0' 

app/gradle


0
使用这个:
 implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation group: 'androidx.fragment', name: 'fragment', version: '1.1.0'
implementation group: 'androidx.vectordrawable', name: 'vectordrawable-animated', version: '1.1.0'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接