leoafarias / fvm

Flutter Version Management: A simple CLI to manage Flutter SDK versions.
https://fvm.app
MIT License
4.42k stars 213 forks source link

[BUG] Cannot change versions to use Dart<3.0 compatible projects #715

Open yieniggu opened 2 months ago

yieniggu commented 2 months ago

Before creating a bug report please make check the following

Describe the bug I set the latest stable version of flutter as global and it works fine, I just created and tested a project. fvm flutter doctor ouputs:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on Ubuntu 22.04.4 LTS 6.5.0-27-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.88.1)
[✓] Connected device (3 available)
[✓] Network resources

However I'm trying to reproduce an example where Dart version is >=2.12.0 <=3.0.0. I try to use flutter v3.7.12 wich uses dart v2.19.6 to meet the constraints. However when I change the version with fvm use 3.7.12, flutter doctor outputs:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on Ubuntu 22.04.4 LTS 6.5.0-27-generic, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ No Java Development Kit (JDK) found; You must have the environment variable JAVA_HOME set and the java binary in your PATH. You can download the JDK from
      https://www.oracle.com/technetwork/java/javase/downloads/.
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[!] Android Studio (version 2023.2)
    ✗ Unable to find bundled Java version.
[✓] VS Code
[✓] Connected device (3 available)
[✓] HTTP Host Availability

And when I try to run the app on debug mode:

Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
main.dart:1
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Exception: Gradle task assembleDebug failed with exit code 1

Honestly don't know if this is the expected behaviour or need some extra steps. Thanks in advance for any help!

leoafarias commented 2 months ago

@yieniggu I need to know the version of FVM. Also, if you are using VSCode, after you switch, can you clear the terminal and just run "flutter" without the FVM prefix? FVM configures the Flutter VSCode settings, so in this case, it would not proxy the commands anymore, which might provide better visibility on what the problem could be.

yieniggu commented 2 months ago

I'm indeed using vs and after switching the version I can run flutter commands. image

FVM version is 3.1.3

leoafarias commented 2 months ago

If this issue does not happen on the latest stable when you do the same thing, it does not seem that this would be an fvm issue, the commands are not been proxied in this case.

yieniggu commented 2 months ago

I changed the version to a much older one (2.0.0) and set it as global. Still getting the same output, or do I need to take extra steps?

  ╔════════════════════════════════════════════════════════════════════════════╗
  ║ A new version of Flutter is available!                                     ║
  ║                                                                            ║
  ║ To update to the latest version, run "flutter upgrade".                    ║
  ╚════════════════════════════════════════════════════════════════════════════╝

Downloading Material fonts...                                      866ms
Downloading Gradle Wrapper...                                      244ms
Downloading package sky_engine...                                1,349ms
Downloading flutter_patched_sdk tools...                         1,480ms
Downloading flutter_patched_sdk_product tools...                 1,527ms
Downloading linux-x64 tools...                                   2,376ms
Downloading linux-x64/font-subset tools...                       1,136ms
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.0, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ No Java Development Kit (JDK) found; You must have the environment variable JAVA_HOME set and the java binary in your PATH. You can download the JDK from
      https://www.oracle.com/technetwork/java/javase/downloads/.
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] Connected device (2 available)

! Doctor found issues in 2 categories.