Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding this plugin results in Build failed with an exception #141

Open
canewsin opened this issue Jul 21, 2023 · 6 comments
Open

Adding this plugin results in Build failed with an exception #141

canewsin opened this issue Jul 21, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@canewsin
Copy link

Describe the bug
Gradle Error : FAILURE: Build failed with an exception.

To Reproduce
Steps to reproduce the behavior

flutter create flutter_test
flutter pub add shared_storage
flutter build apk

Expected behavior
Build should succeed.

Additional context

Gradle log

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:checkReleaseDuplicateClasses'.

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.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.21 (org.jetbrains.kotlin:kotlin-stdlib:1.8.21) and jetified-kotlin-stdlib-jdk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)
dk8-1.5.32 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.32)

 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.

BUILD FAILED in 6s

@canewsin canewsin added the bug Something isn't working label Jul 21, 2023
@alexrintt
Copy link
Owner

Thanks for reporting.

What is the flutter version?

@canewsin
Copy link
Author

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.10.0, on Microsoft Windows [Version 10.0.22621.1848], locale en-IN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.15)
[√] Android Studio (version 2021.2)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.80.1)
[√] Connected device (4 available)

@canewsin
Copy link
Author

@alexrintt

@alexrintt
Copy link
Owner

alexrintt commented Jul 21, 2023

I could reproduce this error in Flutter 3.10.5 as well:

Flutter 3.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 796c8ef792 (5 weeks ago) • 2023-06-13 15:51:02 -0700
Engine • revision 45f6e00911
Tools • Dart 3.0.5 • DevTools 2.23.1

Solution

Please, update your gradle version from ext.kotlin_version = '1.7.10' to ext.kotlin_version = '1.8.0' in /android/build.gradle.

And you'll be able to build successfully:

√  Built build/app/outputs/flutter-apk/app-release.apk (18.4MB).

The error cause is because the shared_storage is using kotlin version 1.8.x and it leads to conflicts within flutter projects using kotlin version 1.7.x.

Ref: https://stackoverflow.com/a/75268089/11793117

@canewsin
Copy link
Author

@alexrintt try to mention this in pub.dev changelog.

@alexrintt
Copy link
Owner

Sure, gonna add soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants