alexrintt / shared-storage

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

Kotlin version errors #145

Closed Voklen closed 10 months ago

Voklen commented 10 months ago

Describe the bug Flutter throws errors when building a project with this plugin, interestingly it still builds the apk even though the errors are thrown.

To Reproduce

flutter create flutter_test_app
cd flutter_test_app
flutter pub add shared_storage
# Change Kotlin version in android/build.gradle to 1.8.10 (or 1.8.0 or 1.9.0, the same thing happens)
flutter build apk

Expected behavior No build errors

Actual behavior

Flutter build output ``` e: /home/sasha/programming/flutter/flutter_test_app/build/shared_storage/.transforms/074fd4077a52b6db7055abd875a5f8b6/transformed/out/jars/classes.jar!/META-INF/shared_storage_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. e: /home/sasha/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.21/43d50ab85bc7587adfe3dda3dbe579e5f8d51265/kotlin-stdlib-1.8.21.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. e: /home/sasha/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.21/43d50ab85bc7587adfe3dda3dbe579e5f8d51265/kotlin-stdlib-1.8.21.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. e: /home/sasha/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.21/43d50ab85bc7587adfe3dda3dbe579e5f8d51265/kotlin-stdlib-1.8.21.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. e: /home/sasha/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.21/d749cd5ae25da36d06e5028785038e24f9d37976/kotlin-stdlib-common-1.8.21.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. Running Gradle task 'assembleRelease'... 116.1s ✓ Built build/app/outputs/flutter-apk/app-release.apk (18.7MB). ```

Version information

Flutter doctor ``` [✓] Flutter (Channel stable, 3.13.3, on Arch Linux 6.4.12-arch1-1, locale en_GB.UTF-8) • Flutter version 3.13.3 on channel stable at /home/sasha/programs/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2524052335 (2 days ago), 2023-09-06 14:32:31 -0700 • Engine revision b8d35810e9 • Dart version 3.1.1 • DevTools version 2.25.0 ```
alexrintt commented 10 months ago

Does the built apk works when running in a real/emulated device?

~Also, seems your project is using gradle 1.6.0 and this project is using gradle 1.8.0, see if #141 works for you.~

Make sure gradle cache is clear before building when gradle version is set to 1.8: https://stackoverflow.com/questions/75260986/the-binary-version-of-its-metadata-is-1-8-0-expected-version-is-1-6-0

Voklen commented 10 months ago

Now it works perfectly, I can't believe I saw the first line with the

e: /home/sasha/programming/flutter/flutter_test_app/build/shared_storage/...

but not the next which pointed to the problem being the gradle cache

e: /home/sasha/.gradle/caches/...

Anyway, thank you for the quick response, I love the project and it's been essential in making Daily Diary