【问题标题】:Android Studio 3.0 DexArchiveBuilderExceptionAndroid Studio 3.0 DexArchiveBuilderException
【发布时间】:2018-04-18 15:32:51
【问题描述】:

我在编译 Instrumentation 测试时遇到此错误。

错误:com.android.builder.dexing.DexArchiveBuilderException:无法处理 /Users/rafaelruizmunoz/SourceTree/Weather/app/build/intermediates/transforms/desugar/androidTest/debug/1.jar

错误:com.android.builder.dexing.DexArchiveBuilderException: dexing org/assertj/core/api/LongPredicateAssert.class 时出错

错误:com.android.dx.cf.code.SimException:在没有 --min-sdk-version >= 24 的情况下使用默认或静态接口方法

我尝试在build.gradle 中启用/禁用multiDexEnabled,但没有任何帮助。

我的androidbuild.gradle

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.**.weather"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

【问题讨论】:

  • 您检查了吗? - Error:com.android.dx.cf.code.SimException: default or static interface method used without --min-sdk-version >= 24你有什么要给你的min-sdk检查build.gradle
  • 我正在更新我的问题
  • gradle.properties 添加android.enableD8=true
  • @Sunny 你能把它添加为答案吗?这对我有用
  • @Sunny 不错的答案!我什至不知道他们的新 D8 编译器 - android-developers.googleblog.com/2017/08/…

标签: java android android-studio gradle


【解决方案1】:

gradle.properties 添加android.enableD8=true 这应该可以工作。

请注意,当您在启用 d8 的情况下将 apk 导出并上传到 Play 商店时存在一个已知错误。从 Play 商店下载时,该应用无法在某些设备上运行。

https://issuetracker.google.com/issues/64740479

【讨论】:

  • 好吧,据我了解,问题不在于将 apk 部署到 Play 商店,而在于生成的应用程序无法在某些设备上运行。这就是为什么他们不建议发布使用 D8 编译的应用程序
  • 对于那些有兴趣了解 android.enableD8 = true 含义的人,请阅读此处:android-developers.googleblog.com/2017/08/…
【解决方案2】:

我也遇到了同样的错误,这是因为 okhttp 而我降级了它的实现形式:

到这里:

implementation "com.squareup.okhttp3:okhttp:3.12.1"

【讨论】:

    【解决方案3】:

    如果您使用的是 guava,您可以尝试将其升级到最新的 android-specific build

    implementation 'com.google.guava:guava:23.0-android'
    

    当我使用非安卓番石榴构建时,这为我修复了错误。

    【讨论】:

      【解决方案4】:

      使用最新的android studio 3.2和gradle,我们也可以通过

      implementation 'com.android.support:multidex:1.0.3' in app build.gradle
      

      【讨论】:

        【解决方案5】:

        我遇到了同样的问题,我通过在运行配置中禁用高级分析解决了这个问题。

        编辑配置 -> 应用程序 -> 分析 -> 启用高级分析(取消选中此选项)。

        【讨论】:

          【解决方案6】:

          将这些行添加到您的 gradle:

          compileOptions {
              sourceCompatibility JavaVersion.VERSION_1_8
              targetCompatibility JavaVersion.VERSION_1_8
          }
          

          【讨论】:

          • 然后将这些行添加到您的 gradle 中:android.enableD8=true
          • gradle.properties
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2018-02-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-04-12
          • 2018-04-14
          相关资源
          最近更新 更多