osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Adding latest version causes the flutter build to fail

Open AMS21 opened this issue 1 year ago • 6 comments

After running.

flutter pub add flutter_osm_plugin

and then

flutter run

I get the following error:

Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_plugin_android_lifecycle:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':flutter_plugin_android_lifecycle:androidJdkImage'.
   > Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JdkImageTransform: /opt/android-sdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /opt/android-studio/jbr/bin/jlink with arguments {--module-path /home/andre/.gradle/caches/8.10/transforms/f3bce71b45fae5b07981439f9f05df82-8a0de900-2314-4d4b-ab23-ecf8d0cf435b/transformed/output/temp/jmod --add-modules java.base --output /home/andre/.gradle/caches/8.10/transforms/f3bce71b45fae5b07981439f9f05df82-8a0de900-2314-4d4b-ab23-ecf8d0cf435b/transformed/output/jdkImage --disable-plugin system-modules}

* 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 10s
Running Gradle task 'assembleDebug'...                             11.1s
Error: Gradle task assembleDebug failed with exit code 1

while before it worked just fine.

AMS21 avatar Nov 26 '24 16:11 AMS21

Output from flutter doctor -v

[✓] Flutter (Channel , 3.24.2, on Manjaro Linux 6.11.2-4-MANJARO, locale en_US.UTF-8)
    • Flutter version 3.24.2 on channel  at /usr/lib/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision archlinuxaur (unknown (arch linux aur package)), 2038-01-19 03:14:08
    • Engine revision a6bd3f1de158
    • Dart version 3.5.1
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /opt/android-sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /opt/android-sdk
    • ANDROID_SDK_ROOT = /opt/android-sdk
    • Java binary at: /opt/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • clang version 18.1.8
    • cmake version 3.30.3
    • ninja version 1.12.1
    • pkg-config version 2.1.1

[✓] Android Studio (version 2024.2)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 82.1.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[✓] IntelliJ IDEA Community Edition (version 2024.1)
    • IntelliJ at /usr/share/idea
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 15 (API 35) (emulator)
    • Linux (desktop)              • linux         • linux-x64   • Manjaro Linux 6.11.2-4-MANJARO

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

AMS21 avatar Nov 26 '24 16:11 AMS21

did you try to run flutter clean and flutter pub get or update gradle version

liodali avatar Nov 30 '24 09:11 liodali

try to override flutter_plugin_android_lifecycle to 2.0.23 like this

dependency_overrides:
      flutter_plugin_android_lifecycle: ^2.0.23

liodali avatar Nov 30 '24 09:11 liodali

I've been trying to use flutter_plugin_osm in a course I'm teaching, and while it worked fine for me, a lot of my students seem to have gotten this same error. Flutter also suggests a fix:

┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] This is likely due to a known bug in Android Gradle Plugin (AGP) versions less than 8.2.1,   │
│ when                                                                                             │
│   1. setting a value for SourceCompatibility and                                                 │
│   2. using Java 21 or above.                                                                     │
│ To fix this error, please upgrade your AGP version to at least 8.2.1. The version of AGP that    │
│ your project uses is likely defined in:                                                          │
│ C:\Users\RuneC\Desktop\Mobile application                                                        │
│ Lectures\flutter_application_5\android\settings.gradle,                                          │
│ in the 'plugins' closure (by the number following "com.android.application").                    │
│  Alternatively, if your project was created with an older version of the templates, it is likely │
│ in the buildscript.dependencies closure of the top-level build.gradle:                           │
│ C:\Users\RuneC\Desktop\Mobile application Lectures\flutter_application_5\android\build.gradle,   │
│ as the number following "com.android.tools.build:gradle:".                                       │
│                                                                                                  │
│ For more information, see:                                                                       │
│ https://issuetracker.google.com/issues/294137077                                                 │
│ https://github.com/flutter/flutter/issues/156304                                                 │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

However, this doesn't seem to have any effect. Also, in the previous comment, shouldn't that be

dependency_overrides:
      flutter_plugin_android_lifecycle: '2.0.23'

(not ^2.0.23?)

floe avatar Mar 20 '25 07:03 floe

did they try to upgrade gradle version?

liodali avatar Mar 20 '25 08:03 liodali

Yes, AFAICT everyone had the most recent gradle version installed.

floe avatar Mar 21 '25 16:03 floe