Удаление сахара в Android с помощью nio. Не удалось преобразовать FakeDependency.jar для соответствия атрибутам.
Добавлена зависимость удаления сахара, как указано в этих ссылках:
- 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
Есть мысли, как я могу обойти эту проблему?
Обновление - 2 июня 2023 г.
Я не стал исправлять эту проблему, поскольку моя основная проблема была устранена. Ниже приведена ссылка на мою основную проблему: Android-приложение разбилось из-за java.lang.NoClassDefFoundError: Не удалось разрешить: [Ljava/nio/file/LinkOption;