flutter doctor 报错

检测本机环境依赖, 执行 $ flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    ✗ Android license status unknown.
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew,
      run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install with Brew:
        brew install ios-deploy
    ! CocoaPods out of date (1.5.0 is recommended).
        CocoaPods is used to retrieve the iOS platform side's plugin code that
        responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work on
        iOS.
        For more info, see https://flutter.io/platform-plugins
      To upgrade:
        brew upgrade cocoapods
        pod setup
[✓] Android Studio (version 3.2)
[!] VS Code (version 1.24.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 4 categories.
1.难解决的: ✗ Android license status unknown , 执行命令👇
$ flutter doctor --android-licenses
A newer version of the Android SDK is required. To update, run:
/Users/zhaoyang/Library/Android/sdk/tools/bin/sdkmanager --update

根据上面提示执行命令👇,有报错

$ /Users/zhaoyang/Library/Android/sdk/tools/bin/sdkmanager --update
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
    ... 5 more

根据搜索javax.xml.bind.JAXBException问题发现缺了包maven
>>>> 以下方式解决:

$ brew install maven
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
istioctl                                   kubeseal                                   pass-otp
==> Updated Formulae
glib ✔               babel                embulk               imagemagick          minio                r
graphite2 ✔          bison                exploitdb            jhipster             minio-mc             rust
harfbuzz ✔           blackbox             fluxctl              jsonnet              nsd                  skopeo
vala ✔               citus                fn                   libcerf              paket                unbound
ammonite-repl        conan                gauche               libcouchbase         pdfpc                vice
annie                container-diff       gdal                 lmdb                 percona-server       webpack
antlr4-cpp-runtime   dnscontrol           gnu-sed              mas                  php-code-sniffer     z3
awscli               docfx                grep                 micronaut            pre-commit

==> Downloading https://www.apache.org/dyn/closer.cgi?path=maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
==> Downloading from http://mirrors.hust.edu.cn/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz
######################################################################## 100.0%
🍺  /usr/local/Cellar/maven/3.6.0: 79 files, 10.1MB, built in 1 minute 31 seconds

再执行下/Users/zhaoyang/Library/Android/sdk/tools/bin/sdkmanager --update

$ /Users/zhaoyang/Library/Android/sdk/tools/bin/sdkmanager --update
Warning: File /Users/zhaoyang/.android/repositories.cfg could not be loaded. 

然后 Android license 解决了 难点

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install with Brew:
        brew install ios-deploy
    ! CocoaPods out of date (1.5.0 is recommended).
        CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
        For more info, see https://flutter.io/platform-plugins
      To upgrade:
        brew upgrade cocoapods
        pod setup
[✓] Android Studio (version 3.2)
[!] VS Code (version 1.24.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 4 categories.

后面比较顺利,接着走 就行

$ flutter doctor --android-licenses
Warning: File /Users/zhaoyang/.android/repositories.cfg could not be loaded.    
4 of 6 SDK package licenses not accepted. 100% Computing updates...             
Review licenses that have not been accepted (y/N)? y

1/4: License android-googletv-license:
---------------------------------------
Terms and Conditions
...

Android license解决好,后面都好说了👇

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install with Brew:
        brew install ios-deploy
    ! CocoaPods out of date (1.5.0 is recommended).
        CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
        For more info, see https://flutter.io/platform-plugins
      To upgrade:
        brew upgrade cocoapods
        pod setup
[✓] Android Studio (version 3.2)
[!] VS Code (version 1.24.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

然后,一步步 没啥意外了

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14 18A391, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[!] VS Code (version 1.24.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.

brew upgrade cocoapods时,我遇到Error: cocoapods not installed问题,那就安装一遍cocoapods。可能又遇到bad response Not Found 404👉解决ruby源问题

2. 咋使用上sdkmanager命令行, 待解决
$ sdkmanager --list
-bash: sdkmanager: command not found
    原文作者:wustzhy
    原文地址: https://www.jianshu.com/p/b170a6f7b984
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞