Google的Flutter和Compose环境悖论
2021-08-07 本文已影响0人
zcwfeng
最近flutter不是更新了空安全吗,升级了Fox版本的Android Studio,似乎这是个bug如下:
flutter doctor
[✓] Flutter (Channel unknown, 2.4.0-4.0.pre, on Mac OS X 10.15.6 19G2005 darwin-x64, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[!] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
[✓] Chrome - develop for the web
[!] Android Studio
✗ Unable to find bundled Java version.
[!] Android Studio (version 2020.3)
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.1)
[✓] VS Code (version 1.58.2)
[✓] Connected device (2 available)
我来说明下这个悖论问题
- flutter的这个操作
Run path/to/sdkmanager --install "cmdline-tools;latest"
执行后会说你的java classloader 找不到,我说我都这么就的java了不会呀。
然后flutter 只支持1.8
- 可是我的Android Studio 升级了Fox最新稳定版本。只支持Java 11
而且出现了bug
[!] Android Studio
✗ Unable to find bundled Java version.
这个我们无论如何都解决不了。Google 的bug太明显
好了我来说解决第一个问题
我们在本地写两套环境,切换jdk8 和 jdk11 然后通过命令切换随时想用那个切换那个
我只写核心配置,用了这么多年java环境变量自己搞
#Java
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
export JRE_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home
export JRE_11_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home/jre
alias jdk8="export JAVA_HOME=$JAVA_8_HOME"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME"
alias jre8="export JRE_HOME=$JRE_8_HOME"
alias jre11="export JRE_HOME=$JRE_11_HOME"
export CLASSPAHT=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:/usr/local/algs4/algs4.jar
随时切换jre,jdk环境
好吧吐槽就到这里,这个bug真的很让人烦啊。