android - 从“编译”切换到“实现”会导致 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'
我还要补充一点,如果我只是将滑翔切换为编译,那么它会给出相同的错误,但依赖不同。谁能帮我解决这个问题?我现在可以继续编译,但我想更新它。
解决方案
经过几个小时的调试,我终于弄明白了
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
将我的库中的 maven gradle 插件从 1.5 更新到 2.1 解决了这个问题
推荐阅读
- internet-explorer - Edge 和 IE 上的动画 SVG(使用 CSS)是否有解决方法?
- python - 有没有办法在 StaticText 中使用整数作为标签
- python - 如何选择在 Pandas 中使用 groupby 首次出现值的行以及随后出现的第一次
- php - 插入多行记录 Codeignite
- c++ - 通过 const 引用传递向量时出现 Intellisense 错误(但项目构建)
- java - 如何停止触发警报的响铃?
- r - r计算数据框中多列的综合得分和可靠性
- c++ - 使用 reinterpret_cast 以外的方法从地址以十六进制格式获取整数
- r - 如果列包含特定值,则将列名分配为单元格值
- c++ - 为什么运算符重载需要引用?