VeryGoodOpenSource / very_good_cli

A Very Good Command-Line Interface for Dart created by Very Good Ventures 🦄
http://cli.vgv.dev
MIT License
2.19k stars 195 forks source link

fix: BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65 #1163

Closed neiljaywarner closed 3 weeks ago

neiljaywarner commented 1 month ago

Description

Android did not "just work" out of the box with zero changes on my 4 day old mac with as minimal of a setup as possible, but flutter create did. (I'm on flutter stable channel Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 2663184aa7 (4 weeks ago) • 2024-09-11 16:27:48 -0500 )

Steps To Reproduce

  1. very_good create flutter_app testapp --desc "test app" --org "com.example" --application-id "com.example.testapp"
  2. File open

Expected Behavior

app launches on android and displays counter app on Android as it does on iOS

Additional Context

Mac m3 pro nov 2023, was purchased 4 days ago and just setup with flutter stable, android studio stable (ladybug just downloaded in the last few days) as minimal configuration as possible.

flutter run --flavor development --target lib/main_development.dart Connected devices: Pixel 6 (mobile) • 24061FDF6003TX • android-arm64 • Android 15 (API 35) iPhone 16 (mobile) • 9DE9E8A1-59FF-4B10-87EC-3969DD66DE54 • ios • com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator) macOS (desktop) • macos • darwin-arm64 • macOS 14.6 23G80 darwin-arm64 Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.6 23G80 darwin-arm64 Chrome (web) • chrome • web-javascript • Google Chrome 129.0.6668.100

No wireless devices were found.

[1]: Pixel 6 (24061FDF6003TX) [2]: iPhone 16 (9DE9E8A1-59FF-4B10-87EC-3969DD66DE54)

[4]: Mac Designed for iPad (mac-designed-for-ipad)

Please choose one (or "q" to quit): 1 Launching lib/main_development.dart on Pixel 6 in debug mode...

FAILURE: Build failed with an exception.

BUILD FAILED in 788ms Running Gradle task 'assembleDevelopmentDebug'... 1,287ms

┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ [!] Your project's Gradle version is incompatible with the Java version that Flutter is using for Gradle. │ │ │ │ If you recently upgraded Android Studio, consult the migration guide at https://flutter.dev/to/to/java-gradle-incompatibility. │ │ │ │ Otherwise, to fix this issue, first, check the Java version used by Flutter by running flutter doctor --verbose. │ │ │ │ Then, update the Gradle version specified in /Users/neil/code/redacted_dir/android/gradle/wrapper/gradle-wrapper.properties to be │ │ compatible with that Java version. See the link below for more information on compatible Java/Gradle versions: │ │ https://docs.gradle.org/current/userguide/compatibility.html#java │ │ │ │ │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ Error: Gradle task assembleDevelopmentDebug failed with exit code 1 neil@Neils-MacBook-Pro downstream %

here is relevant part of flutter doctor --verbose output ` neil@Neils-MacBook-Pro downstream % flutter doctor --verbose [✓] Flutter (Channel stable, 3.24.3, on macOS 14.6 23G80 darwin-arm64, locale en-US) • Flutter version 3.24.3 on channel stable at /Users/neil/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (4 weeks ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/neil/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11) • All Android licenses accepted.

`

Jbwzx commented 1 month ago

To fix immediate issue:

  1. Bump gradle wrapper version in android/gradle/wrapper/gradle-wrapper.properties ->
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
  1. Bump android app and kotlin android plugin versions in android/settings.gradle
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
  1. Update compileOptions and kotlinOptions in android/app/build.gradle
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = JavaVersion.VERSION_1_8
}
neiljaywarner commented 1 month ago

1) @Jbwzx thanks so much. Do you have an approximate ETA of when this will be fixed in a new version 2) also - does anyone have any thoughts around a) Making it easier to "tell" which version of flutter a vgv cli version works with and/or b) being able to specify it or even c) Making it "work on top of it" a little better.

In other words, it "feels" to me like the purpose of VGV cli is to handle flavors and dart/flutter best practices and architecture and testing and github actions - none of which should ever break the ability to compile and launch on any platform.

I imagine it might not be a small effort but is there any way under the hood to achieve that goal?

tomarra commented 1 month ago

Hi everyone. Thanks for the comments here. This is a typical pattern we see and have to chase unfortunately. As the Flutter team creates releases not all the updates they make are called out well in the release docs. Minor updates like this tend to get pulled into other points in the notes so they get missed.

I did a brand new flutter create to confirm that the base Flutter application setup uses these versions as well. This means we need to update our templates as well. Let me try and work on this with our teams over the next week or so. In the mean time the updates posted by @Jbwzx should be a manual fix you can apply to your codebase to get unblocked with new projects.

tomarra commented 4 weeks ago

Step one, getting the templates updated in very_good_templates is complete. Opened a PR for updating the bundles in CLI with #1167. Currently this is blocked due to a CI issue that is being looked into.

tomarra commented 3 weeks ago

With #1167 merged going to close this as fixed. This will be in the next release which is being prepped by #1170