alexrintt / shared-storage

Flutter plugin to work with Android external storage.
http://alexrintt.io/shared-storage/
MIT License
54 stars 26 forks source link

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

Open canewsin opened 1 year ago

canewsin commented 1 year ago

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 Fix dependency resolution errors. * 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 6s
alexrintt commented 1 year ago

Thanks for reporting.

What is the flutter version?

canewsin commented 1 year ago

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 commented 1 year ago

@alexrintt

alexrintt commented 1 year ago

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 commented 1 year ago

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

alexrintt commented 1 year ago

Sure, gonna add soon