Glide 在构建应用程序时显示错误

Glide is showing error while building app

首先我尝试将 glide 更新到 4.6.0 但它有一些错误然后我决定将它降级到 4.4.0 但现在它甚至没有构建应用程序。我试图在 SOgithub 中搜索很多问题,但我找不到任何 .请帮助修复我的错误。

错误:

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.

java.io.IOException: Can't write [C:\Users\Srinu\Infinity\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\Srinu.gradle\caches\modules-2\files-2.1\com.github.bumptech.glide\glide.4.0d55ca453af56b7f7e6b494c1781755d89047d4f\glide-4.4.0.jar(;;;;;;**.class)] (Duplicate zip entry [glide-4.4.0.jar:com/bumptech/glide/util/Synthetic.class]))

Gradle 依赖关系:

     compile('com.github.bumptech.glide:glide:4.4.0@aar') {
    transitive = true;//I saw this in a question but even it couldn't solve the 
    issue
    }
    annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
    compile 'com.github.bumptech.glide:annotations:4.4.0'

由于 glide 是一个大库,在添加 glide 的同时,方法的数量增加到 64k (1 Dex) 以上。因此,您需要在 gradle 中添加 Multidex 支持。看看他的做法。

Enable Multidex for Apps with Over 64K Methods

经过多次尝试,我终于尝试了一种不同的方法,它解决了我的问题。 我刚刚从依赖项中删除了 '@aar' 并且 compile 'com.github.bumptech.glide:annotations:4.4.0' 我的滑行工作正常。但我想知道错误在哪里我真的无法找出真正的问题。

所以现在最后的 gradle 是:

compile('com.github.bumptech.glide:glide:4.4.0') {
    transitive = true;
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'