【问题标题】:Gradle desugaring failed, Hierarchy is incompleteGradle 脱糖失败,层次结构不完整
【发布时间】:2020-03-09 19:00:41
【问题描述】:

我正在处理这个项目:https://github.com/muxinc/mux-stats-sdk-exoplayer/tree/min_sdk_version_fix 这是一个名为 demo 的 Android 应用程序,它依赖于来自同一个名为 MuxExoPlayer 的项目的模块,该项目依赖于 MuxCore.jar 库。

当我尝试使用 minSdkVersion 16 编译项目时,我在 jar 文件上遇到了脱糖问题,错误:

Transform artifact full.jar (project :MuxExoPlayer) with DexingWithClasspathTransform
AGPBI: {"kind":"error","text":"Default method desugaring of `com.mux.stats.sdk.muxstats.MuxStatsExoPlayer` failed because it's hierarchy is incomplete. The class `com.mux.stats.sdk.core.events.EventBus` is missing and it is the declared super class of `com.mux.stats.sdk.muxstats.MuxBaseExoPlayer`","sources":[{}],"tool":"D8"}

当我使用 minSdkVersion 24 编译时,我没有收到此错误并且项目编译正常。

MuxCore.jar 也是用 gradle 构建的,这里是 gradle.build:

apply plugin: 'java-library'

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}
tasks.withType(JavaCompile) {
    sourceCompatibility = '1.7'
    targetCompatibility = '1.7'
}

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:23.0'
    implementation 'org.json:json:20180130'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.4'
    testImplementation 'org.mockito:mockito-core:2.23.4'
}

我在这里缺少什么? 我需要如何编译 MuxCore 才能使用 android minSdkVersion 16 进行编译?

【问题讨论】:

    标签: android android-studio gradle jar dependencies


    【解决方案1】:

    我有同样的问题,也在 Mux github repo 中创建了一张票,但无法让它工作......如果你将 minSdk 更新为 24,它将工作......

    https://github.com/muxinc/mux-stats-sdk-exoplayer/issues/19

    对我有用的是:不要将 MuxStatsExoPlayer 作为模块添加,而是将应用模块中的所有文件和类直接添加到项目中,它应该可以工作。

    【讨论】:

    • 嗨 Nicolas,感谢您的回复,我同意您的意见,这是我尝试过的方法之一,它确实有效,但在公司政策方面这是不可接受的,这个项目需要保留java库。另一种解决方案是将其转换为 Android lib 模块 (AAR) 并将该模块的最小 SDK 版本设置为 16,一切都很好,但这又不是一个选项
    • 哦!所以我建议你继续在 github 票上讨论这个问题。但据我所知,这些是唯一的选择,更新到 minSdk 24 或将这些类复制并粘贴到您自己的项目中......很抱歉不能更好地帮助您,我和您的情况相同 =D。
    猜你喜欢
    • 2013-12-22
    • 1970-01-01
    • 2023-04-08
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-18
    • 2022-12-22
    相关资源
    最近更新 更多