首页 > 解决方案 > 从“编译”切换到“实现”会导致 DexPathList 错误

问题描述

我正在尝试更新我的依赖项以使用新的实现/api 规范而不是编译。这是我正在编写的一个通用库,然后我通过 jitpack 在我的应用程序中使用它。

当我从编译到实现的简单切换时,在我的应用程序中使用库时出现以下错误(只是重要的部分):

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/bumptech/glide/request/RequestOptions;

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.bumptech.glide.request.RequestOptions" on path: DexPathList

我尝试过清洁和重建,但没有帮助。第二次我切换回编译调用一切正常。

我会注意到该库在所有情况下都可以正常构建。

以下用法有效(尽管警告我编译将被弃用):

    compile fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    compile 'com.github.ybq:Android-SpinKit:1.2.0'
    compile 'io.reactivex.rxjava2:rxandroid:2.1.0'
    compile 'androidx.appcompat:appcompat:1.0.2'
    compile "com.github.bumptech.glide:glide:4.4.0"
    compile 'androidx.recyclerview:recyclerview:1.0.0'
    compile "com.github.chrisbanes:PhotoView:1.3.1"
    compile 'com.google.android.material:material:1.0.0'

以下给出了上述错误(如果我使用 api 而不是实现,也会给出错误):

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.github.ybq:Android-SpinKit:1.2.0'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation "com.github.bumptech.glide:glide:4.4.0"
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation "com.github.chrisbanes:PhotoView:1.3.1"
    implementation 'com.google.android.material:material:1.0.0'

我还要补充一点,如果我只是将滑翔切换为编译,那么它会给出相同的错误,但依赖不同。谁能帮我解决这个问题?我现在可以继续编译,但我想更新它。

标签: androidgradleandroid-gradle-plugin

解决方案


经过几个小时的调试,我终于弄明白了

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

将我的库中的 maven gradle 插件从 1.5 更新到 2.1 解决了这个问题


推荐阅读