提问人:Dhagz 提问时间:5/30/2023 最后编辑:Dhagz 更新时间:6/2/2023 访问量:140
使用 nio 进行 Android 脱糖 无法将 FakeDependency.jar 转换为匹配属性
Android Desugaring with nio Failed to transform FakeDependency.jar to match attributes
问:
按照以下链接中的说明添加了脱糖依赖项:
- https://developer.android.com/studio/write/java11-nio-support-table
- https://developer.android.com/studio/write/java8-support#library-desugaring
我已经在我的应用程序中添加了这些:build.gradle
android {
defaultConfig {
// Required when setting minSdkVersion to 20 or lower
multiDexEnabled true
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs_nio:2.0.1"
}
错误
当我构建应用程序时,我收到以下错误:
完整的构建日志可以在这里找到:https://pastebin.com/weKPjZ6E
下面是经过精简的构建日志。
Starting Gradle Daemon...
Gradle Daemon started in 2 s 115 ms
> Configure project :app
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
ComposeOptions.kotlinCompilerVersion is deprecated. Compose now uses the kotlin compiler defined in your buildscript.
Warning: 'kapt.use.worker.api' is deprecated and scheduled to be removed in Kotlin 1.8 release.
By default Kapt plugin is using Gradle workers to run annotation processing. Running annotation processing
directly in the Kotlin compiler is deprecated.
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
FAILURE: Build failed with an exception.
* What went wrong:
A build operation failed.
Could not resolve all files for configuration ':app:detachedConfiguration21'.
Could not resolve all files for configuration ':app:detachedConfiguration21'.
Failed to transform FakeDependency.jar to match attributes {artifactType=_internal-d8-desugar-methods, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
Execution failed for D8BackportedMethodsGenerator: C:\Users\User1\.gradle\android\FakeDependency.jar.
Cannot invoke "com.android.tools.r8.internal.GV.a(com.android.tools.r8.Diagnostic)" because "<parameter3>" is null
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException: A build operation failed.
Could not resolve all files for configuration ':app:detachedConfiguration21'.
Could not resolve all files for configuration ':app:detachedConfiguration21'.
Failed to transform FakeDependency.jar to match attributes {artifactType=_internal-d8-desugar-methods, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
Execution failed for D8BackportedMethodsGenerator: C:\Users\User1\.gradle\android\FakeDependency.jar.
Cannot invoke "com.android.tools.r8.internal.GV.a(com.android.tools.r8.Diagnostic)" because "<parameter3>" is null
at org.jetbrains.plugins.gradle.model.ProjectImportAction.addBuildModels(ProjectImportAction.java:412)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:138)
at org.jetbrains.plugins.gradle.model.ProjectImportAction.execute(ProjectImportAction.java:42)
org.gradle.internal.operations.MultipleBuildOperationFailures: A build operation failed.
Could not resolve all files for configuration ':app:detachedConfiguration21'.
at org.gradle.tooling.internal.provider.runner.DefaultBuildController.run(DefaultBuildController.java:142)
at org.gradle.tooling.internal.consumer.connection.NestedActionAwareBuildControllerAdapter.run(NestedActionAwareBuildControllerAdapter.java:55)
at org.jetbrains.plugins.gradle.model.ProjectImportAction$MyBuildController.run(ProjectImportAction.java:696)
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:detachedConfiguration21'.
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:1524)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$3700(DefaultConfiguration.java:159)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$DefaultResolutionHost.rethrowFailure(DefaultConfiguration.java:2174)
at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.visitContents(DefaultConfiguration.java:1496)
at org.gradle.api.internal.file.AbstractFileCollection.visitStructure(AbstractFileCollection.java:375)
at org.gradle.api.internal.file.CompositeFileCollection.lambda$visitContents$0(CompositeFileCollection.java:119)
at org.gradle.api.internal.file.collections.UnpackingVisitor.add(UnpackingVisitor.java:64)
at org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection$UnresolvedItemsCollector.visitContents(DefaultConfigurableFileCollection.java:372)
at org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection.visitChildren(DefaultConfigurableFileCollection.java:284)
at org.gradle.api.internal.file.CompositeFileCollection.visitContents(CompositeFileCollection.java:119)
at org.gradle.api.internal.file.AbstractFileCollection.getFiles(AbstractFileCollection.java:129)
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Failed to transform FakeDependency.jar to match attributes {artifactType=_internal-d8-desugar-methods, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
at org.gradle.api.internal.artifacts.transform.TransformingAsyncArtifactListener$TransformedArtifact.lambda$visit$2(TransformingAsyncArtifactListener.java:232)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
Caused by: org.gradle.api.internal.artifacts.transform.TransformException: Execution failed for D8BackportedMethodsGenerator: C:\Users\User1\.gradle\android\FakeDependency.jar.
at org.gradle.api.internal.artifacts.transform.DefaultTransformerInvocationFactory$1.lambda$mapResult$3(DefaultTransformerInvocationFactory.java:159)
at org.gradle.internal.Try$Failure.mapFailure(Try.java:273)
... 85 more
Caused by: java.lang.NullPointerException: Cannot invoke "com.android.tools.r8.internal.GV.a(com.android.tools.r8.Diagnostic)" because "<parameter3>" is null
at com.android.tools.r8.internal.Vg.a(R8_4.0.52_5a340ca2823c7e792fe09805c75f749b9d398d230bc0518bb54ae9b6b50addbe:39)
at com.android.tools.r8.internal.Vg.a(R8_4.0.52_5a340ca2823c7e792fe09805c75f749b9d398d230bc0518bb54ae9b6b50addbe:1)
at com.android.tools.r8.BackportedMethodListCommand$Builder.build(R8_4.0.52_5a340ca2823c7e792fe09805c75f749b9d398d230bc0518bb54ae9b6b50addbe:36)
at com.android.builder.dexing.D8DesugaredMethodsGenerator.generate(D8DesugaredMethodsGenerator.kt:43)
at com.android.build.gradle.internal.utils.D8BackportedMethodsGenerator.transform(DesugarLibUtils.kt:369)
... 111 more
* Get more help at https://help.gradle.org
BUILD FAILED in 18s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings
有什么想法可以解决这个问题吗?
更新 - 2023/6/2
我没有继续解决这个问题,因为我的主要问题已经解决。以下是我的主要问题的链接: Android 应用程序崩溃,java.lang.NoClassDefFoundError:解决失败:[Ljava/nio/file/LinkOption;
答: 暂无答案
评论