java - Android - 使用最小 sdk 版本将字节码转换为 Dex 时出错

标签 java android kotlin dex

我正在尝试运行我的应用程序并不断遇到错误:

Error:Error converting bytecode to dex:
Cause: default or static interface method used without --min-sdk-version >= 24

我不确定哪里出了问题,因为它没有提供太多信息。之前一直在运行。我看过类似的问题,但它们是不同的。它们都与 build.gradle 中的依赖项有关,所以我在下面展示了这一点。

compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-v4:25.3.1'

compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile group: 'com.googlecode.libphonenumber', name: 'libphonenumber', version: '8.4.3'
compile group: 'com.pubnub', name: 'pubnub-gson', version: '4.6.2'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.7.3'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.7.3'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.3'
compile group: 'com.google.guava', name: 'guava', version: '21.0'
compile group: 'joda-time', name: 'joda-time', version: '2.9.7'
compile 'com.google.android.gms:play-services-maps:10.2.6'
compile 'com.google.android.gms:play-services-location:10.2.6'

最佳答案

这里的罪魁祸首是 Guava

compile group: 'com.google.guava', name: 'guava', version: '21.0'

将其更改为:

compile group: 'com.google.guava', name: 'guava', version: '22.0'

它会起作用

你可以在更新日志中看到: https://github.com/google/guava/wiki/Release21

关于java - Android - 使用最小 sdk 版本将字节码转换为 Dex 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44274066/

相关文章:

java - 在多线程(Java 或 .Net)程序中,我可以假设复制变量是原子的吗?

java - 如何从 Android Studio 中 fragment 的 XML 布局导航到相应的 java 类?

java - 显示异步 httprequest 的进度对话框

android - 动画无法通过硬件加速正常工作

android - 如何在android中完全显示标签标题

android - 为什么编译器找不到 android.R.id.home 常量?

android - 如何在kotlin中实现Android in app purchase?

java - 单击打开 Android 中的特定文件夹

android - 声明为不可为 null 的 Kotlin 属性即使已初始化值也可以为 null

java等待swing.timer任务完成后再执行下一个任务