针对Android Gradle构建工具3.3.0进行构建时,有关捆绑的Kotlin运行时库的警告

时间:2019-01-23 22:27:52

标签: android gradle kotlin gradle-plugin

我正在用Kotlin构建一个Gradle插件,该插件可以根据Android构建工具进行编译,因此我可以使用Android Transform API,还可以在运行时从Android插件获取Android构建配置。到目前为止,我对此配置没有任何问题:

apply plugin: 'java-gradle-plugin'
apply plugin: 'kotlin'
apply plugin: 'maven'

repositories {
    google()
    jcenter()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation 'commons-io:commons-io:2.6'
    implementation 'org.ow2.asm:asm:7.0'

    compileOnly gradleApi()
    compileOnly('com.android.tools.build:gradle:3.2.1') {
        exclude group: 'org.jetbrains.kotlin'
    }
}

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

请注意,我必须从Android构建工具库中排除Kotlin传递依赖项,否则可能会收到Kotlin版本警告。这很好。

但是,当我将Android构建工具升级到3.3.0 时,在Gradle构建过程中会收到以下警告:

  

w:类路径中的某些JAR文件具有Kotlin Runtime库   捆绑在一起。这可能导致难以调试的问题,如果   有一个不同版本的Kotlin Runtime库   类路径。考虑从类路径中删除这些库

     

w:/path/to/.gradle/caches/modules-2/files-2.1/com.android.tools.build/builder/3.3.0/de1cc306a8a198f59d56cb9a909d9a4f516116e7/builder-3.3.0.jar:   库中捆绑了Kotlin运行时

该警告在实践中似乎没有带来任何问题(一切仍然可以构建并运行),但是显然我不喜欢在那里发出警告,而且我也不知道是什么原因引起的。当我查看依赖关系树时,我什至没有看到任何不是来自我自己的声明的捆绑的Kotlin库:

compileClasspath - Compile classpath for compilation 'main' (target  (jvm)).
+--- com.android.tools.build:gradle:3.3.0
|    +--- com.android.tools.build:builder:3.3.0
|    |    +--- com.android.tools.build:builder-model:3.3.0
|    |    |    \--- com.android.tools:annotations:26.3.0
|    |    +--- com.android.tools.build:builder-test-api:3.3.0
|    |    |    \--- com.android.tools.ddms:ddmlib:26.3.0
|    |    |         +--- com.android.tools:common:26.3.0
|    |    |         |    +--- com.android.tools:annotations:26.3.0
|    |    |         |    \--- com.google.guava:guava:26.0-jre
|    |    |         |         +--- com.google.code.findbugs:jsr305:3.0.2
|    |    |         |         +--- org.checkerframework:checker-qual:2.5.2
|    |    |         |         +--- com.google.errorprone:error_prone_annotations:2.1.3 -> 2.2.0
|    |    |         |         +--- com.google.j2objc:j2objc-annotations:1.1
|    |    |         |         \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
|    |    |         \--- net.sf.kxml:kxml2:2.3.0
|    |    +--- com.android.tools:sdklib:26.3.0
|    |    |    +--- com.android.tools.layoutlib:layoutlib-api:26.3.0
|    |    |    |    +--- com.android.tools:common:26.3.0 (*)
|    |    |    |    +--- net.sf.kxml:kxml2:2.3.0
|    |    |    |    +--- com.android.tools:annotations:26.3.0
|    |    |    |    \--- org.jetbrains:annotations:13.0
|    |    |    +--- com.android.tools:dvlib:26.3.0
|    |    |    |    \--- com.android.tools:common:26.3.0 (*)
|    |    |    +--- com.android.tools:repository:26.3.0
|    |    |    |    +--- com.android.tools:common:26.3.0 (*)
|    |    |    |    +--- com.sun.activation:javax.activation:1.2.0
|    |    |    |    +--- org.apache.commons:commons-compress:1.12
|    |    |    |    +--- org.glassfish.jaxb:jaxb-runtime:2.2.11
|    |    |    |    |    +--- org.glassfish.jaxb:jaxb-core:2.2.11
|    |    |    |    |    |    +--- javax.xml.bind:jaxb-api:2.2.12-b140109.1041
|    |    |    |    |    |    +--- org.glassfish.jaxb:txw2:2.2.11
|    |    |    |    |    |    \--- com.sun.istack:istack-commons-runtime:2.21
|    |    |    |    |    +--- org.jvnet.staxex:stax-ex:1.7.7
|    |    |    |    |    \--- com.sun.xml.fastinfoset:FastInfoset:1.2.13
|    |    |    |    \--- com.google.jimfs:jimfs:1.1
|    |    |    |         \--- com.google.guava:guava:18.0 -> 26.0-jre (*)
|    |    |    +--- com.google.code.gson:gson:2.8.0
|    |    |    +--- org.apache.commons:commons-compress:1.12
|    |    |    +--- org.apache.httpcomponents:httpmime:4.5.2
|    |    |    |    \--- org.apache.httpcomponents:httpclient:4.5.2
|    |    |    |         +--- org.apache.httpcomponents:httpcore:4.4.4 -> 4.4.5
|    |    |    |         +--- commons-logging:commons-logging:1.2
|    |    |    |         \--- commons-codec:commons-codec:1.9
|    |    |    \--- org.apache.httpcomponents:httpcore:4.4.5
|    |    +--- com.android.tools:sdk-common:26.3.0
|    |    |    +--- com.android.tools:sdklib:26.3.0 (*)
|    |    |    +--- com.android.tools.build:builder-test-api:3.3.0 (*)
|    |    |    +--- com.android.tools.build:builder-model:3.3.0 (*)
|    |    |    +--- com.android.tools.ddms:ddmlib:26.3.0 (*)
|    |    |    +--- org.bouncycastle:bcpkix-jdk15on:1.56
|    |    |    |    \--- org.bouncycastle:bcprov-jdk15on:1.56
|    |    |    +--- org.bouncycastle:bcprov-jdk15on:1.56
|    |    |    +--- com.google.protobuf:protobuf-java:3.4.0
|    |    |    \--- javax.inject:javax.inject:1
|    |    +--- com.android.tools:common:26.3.0 (*)
|    |    +--- com.android.tools.build:manifest-merger:26.3.0
|    |    |    +--- com.android.tools:common:26.3.0 (*)
|    |    |    +--- com.android.tools:sdklib:26.3.0 (*)
|    |    |    +--- com.android.tools:sdk-common:26.3.0 (*)
|    |    |    +--- com.google.code.gson:gson:2.8.0
|    |    |    \--- net.sf.kxml:kxml2:2.3.0
|    |    +--- com.android.tools.ddms:ddmlib:26.3.0 (*)
|    |    +--- com.android.tools.analytics-library:protos:26.3.0
|    |    |    \--- com.google.protobuf:protobuf-java:3.4.0
|    |    +--- com.android.tools.analytics-library:shared:26.3.0
|    |    |    +--- com.android.tools.analytics-library:protos:26.3.0 (*)
|    |    |    +--- com.android.tools:annotations:26.3.0
|    |    |    +--- com.android.tools:common:26.3.0 (*)
|    |    |    +--- com.google.guava:guava:26.0-jre (*)
|    |    |    \--- com.google.code.gson:gson:2.8.0
|    |    +--- com.android.tools.analytics-library:tracker:26.3.0
|    |    |    +--- com.android.tools:annotations:26.3.0
|    |    |    +--- com.android.tools:common:26.3.0 (*)
|    |    |    +--- com.android.tools.analytics-library:protos:26.3.0 (*)
|    |    |    +--- com.android.tools.analytics-library:shared:26.3.0 (*)
|    |    |    +--- com.google.protobuf:protobuf-java:3.4.0
|    |    |    \--- com.google.guava:guava:26.0-jre (*)
|    |    +--- com.android.tools.build:apksig:3.3.0
|    |    +--- com.android.tools.build:apkzlib:3.3.0
|    |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.2
|    |    |    +--- com.google.guava:guava:23.0 -> 26.0-jre (*)
|    |    |    +--- org.bouncycastle:bcpkix-jdk15on:1.56 (*)
|    |    |    +--- org.bouncycastle:bcprov-jdk15on:1.56
|    |    |    \--- com.android.tools.build:apksig:3.3.0
|    |    +--- com.squareup:javawriter:2.5.0
|    |    +--- org.bouncycastle:bcpkix-jdk15on:1.56 (*)
|    |    +--- org.bouncycastle:bcprov-jdk15on:1.56
|    |    +--- org.ow2.asm:asm:6.0 -> 7.0
|    |    +--- org.ow2.asm:asm-tree:6.0
|    |    |    \--- org.ow2.asm:asm:6.0 -> 7.0
|    |    +--- org.ow2.asm:asm-commons:6.0
|    |    |    \--- org.ow2.asm:asm-tree:6.0 (*)
|    |    +--- org.ow2.asm:asm-util:6.0
|    |    |    \--- org.ow2.asm:asm-tree:6.0 (*)
|    |    +--- it.unimi.dsi:fastutil:7.2.0
|    |    +--- net.sf.jopt-simple:jopt-simple:4.9
|    |    \--- com.googlecode.json-simple:json-simple:1.1
|    +--- com.android.tools.analytics-library:shared:26.3.0 (*)
|    +--- com.android.tools.analytics-library:crash:26.3.0
|    |    +--- com.android.tools:annotations:26.3.0
|    |    +--- com.google.guava:guava:26.0-jre (*)
|    |    +--- org.apache.httpcomponents:httpmime:4.5.2 (*)
|    |    +--- org.apache.httpcomponents:httpcore:4.4.5
|    |    \--- org.apache.httpcomponents:httpclient:4.5.2 (*)
|    +--- com.android.tools.lint:lint-gradle-api:26.3.0
|    |    +--- com.android.tools:sdklib:26.3.0 (*)
|    |    +--- com.android.tools.build:builder-model:3.3.0 (*)
|    |    +--- com.android.tools.build:gradle-api:3.3.0
|    |    |    +--- com.android.tools.build:builder-model:3.3.0 (*)
|    |    |    +--- com.android.tools.build:builder-test-api:3.3.0 (*)
|    |    |    \--- com.google.guava:guava:26.0-jre (*)
|    |    \--- com.google.guava:guava:26.0-jre (*)
|    +--- com.android.tools.build:gradle-api:3.3.0 (*)
|    +--- androidx.databinding:databinding-compiler-common:3.3.0
|    |    +--- androidx.databinding:databinding-common:3.3.0
|    |    +--- com.android.databinding:baseLibrary:3.3.0
|    |    +--- org.antlr:antlr4:4.5.3
|    |    +--- commons-io:commons-io:2.4 -> 2.6
|    |    +--- com.googlecode.juniversalchardet:juniversalchardet:1.0.3
|    |    +--- com.google.guava:guava:26.0-jre (*)
|    |    +--- com.squareup:javapoet:1.8.0
|    |    +--- com.google.code.gson:gson:2.8.0
|    |    +--- com.android.tools:annotations:26.3.0
|    |    \--- com.android.tools.build.jetifier:jetifier-core:1.0.0-beta02
|    |         \--- com.google.code.gson:gson:2.8.0
|    +--- com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api
|    +--- org.ow2.asm:asm:6.0 -> 7.0
|    +--- org.ow2.asm:asm-analysis:6.0
|    |    \--- org.ow2.asm:asm-tree:6.0 (*)
|    +--- org.ow2.asm:asm-commons:6.0 (*)
|    +--- org.ow2.asm:asm-util:6.0 (*)
|    +--- net.sf.jopt-simple:jopt-simple:4.9
|    +--- net.sf.proguard:proguard-gradle:6.0.3
|    |    \--- net.sf.proguard:proguard-base:6.0.3
|    +--- com.android.tools.build:bundletool:0.6.0
|    |    +--- com.google.auto.value:auto-value:1.5.2
|    |    +--- com.android.tools.build:aapt2-proto:0.3.1
|    |    |    \--- com.google.protobuf:protobuf-java:3.4.0
|    |    +--- com.google.errorprone:error_prone_annotations:2.2.0
|    |    +--- com.google.guava:guava:26.0-jre (*)
|    |    +--- com.google.protobuf:protobuf-java:3.4.0
|    |    \--- com.google.protobuf:protobuf-java-util:3.4.0
|    |         +--- com.google.protobuf:protobuf-java:3.4.0
|    |         +--- com.google.guava:guava:19.0 -> 26.0-jre (*)
|    |         \--- com.google.code.gson:gson:2.7 -> 2.8.0
|    +--- com.android.tools.build.jetifier:jetifier-core:1.0.0-beta02 (*)
|    \--- com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02
|         +--- org.ow2.asm:asm:6.0 -> 7.0
|         +--- org.ow2.asm:asm-util:6.0 (*)
|         +--- org.ow2.asm:asm-commons:6.0 (*)
|         +--- org.jdom:jdom2:2.0.6
|         \--- com.android.tools.build.jetifier:jetifier-core:1.0.0-beta02 (*)
+--- org.jetbrains.kotlin:kotlin-stdlib:1.3.20
|    +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.20
|    \--- org.jetbrains:annotations:13.0
+--- commons-io:commons-io:2.6
\--- org.ow2.asm:asm:7.0

有什么方法可以清除此警告,还是我在这里查看错误?

Gradle版本为5.1.1。

1 个答案:

答案 0 :(得分:0)

我跟踪了道格在评论中链接的问题跟踪器,发现如果有人想知道,此问题已在 Android Studio 3.3 Android Studio 3.4 中得到解决。 / p>

Here is the relevant comment