Closed kanntim closed 1 year ago
Hello, I am having the exact same issue
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)
Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 54s
Exception: Gradle task assembleDebug failed with exit code 1
And it looks like I fixed ( at least temporarily) the issue
Android Studio Electric Eel | 2022.1.1 Patch 2
Build #AI-221.6008.13.2211.9619390, built on February 17, 2023
in android/build gradle I changed the kotlin version from the default set by Android studio
ext.kotlin_version = '1.8.0'
in app/build.gradle, I also changed kotlin library
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
This provides a temporary solution. No errors appear, but when trying to compile, a broken file is obtained.
When you try to create a bundle/apk? I've been running in debug mode on my phone and it is working fine.
I had to abandon this plugin in the end
Same issue for me too. The issue is not just for Flutter, it is also for Kotlin and Java. The problem came with Android Studio Electric Eel I installed the previous version of AS but not resolved. I deleted the .gradle folder but still the issue remains.
Yes, can confirm that the issue appears after upgrading to a new release of Android Studio. I will take care of fixing plugins soon.
Can you look into this? Build Dependencies Error My issue ha been resolved by changing implementation to api, api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0" but app in not running even it shows > Launching 'app' on DEVICE
@kanntim Which Kotlin version do you have in your project? As @afridi315 pointed out with Kotlin 1.8.0 it might happen that this error appears. We have the same issue with one of dependencies updates, for example: https://github.com/fluttercommunity/plus_plugins/actions/runs/4352473482/jobs/7605300754?pr=1578
We will update Kotlin in all packages soon, though.
Update on the issue.
This error about duplicates happens on projects which have Kotlin 1.8.0 or newer and some depenedencies that declare Kotlin dependency in with ***kotlin-stdlib-jdk7*
or ***kotlin-stdlib-jdk8*
. Mixing such declarations is supposed to show errors as described here: https://kotlinlang.org/docs/whatsnew18.html#updated-jvm-compilation-target
It is supposed that Kotlin plugin would take care of merging duplicates: https://kotlinlang.org/docs/whatsnew18.html#usage-of-the-latest-kotlin-stdlib-version-in-transitive-dependencies however, it doesn't work well.
To resolve the issue and not wait till all dependencies switch to just kotlin-stdlib
you can add such constraints in the dependencies
section of your build.gradle file to the already declared Kotlin version:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib and to not fail builds due duplicate classes")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib and to not fail builds due duplicate classes")
}
}
}
Tested it on a few projects already and can confirm that it resolves the issue.
By uninstalling Android Studio and reinstalling it again resolved everything for me.
changing theext.kotlin_version = "1.8.10"
works for me
check here
Platform
android-33-ext5
Plugin
share_plus
Version
6.3.1
Flutter SDK
3.7.10
Steps to reproduce
I tried using the plugin even in an empty Flatter starter project, and got the build error "Build failed with an exception". I get the same errors in my project. I also running the example project whith same errors.
I really hope that a solution will be found
Code Sample
Logs
Flutter Doctor
Checklist before submitting a bug
flutter pub upgrade
flutter clean