Repository: flutter
Issue: tool should validate that discovered java version is 1.8 before running certain SDK tools
Labels: platform-android,tool,a: first hour,a: quality,P2,team-android,triaged-android

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please tell us exactly how to reproduce the problem you are running into. -->

1. clone this repo
2. install SDK command-line tools by unzipping the file available at [developer.android](https://developer.android.com/studio/) (for Linux; I'm on Ubuntu 18.04) to `$HOME/cmdline-tools`. This provides me with an `sdkmanager` executable at `$HOME/cmdline-tools/tools/bin/sdkmanager`
3. prep SDK by mimicking the commands listed in [the file](https://github.com/flutter/flutter/blob/master/dev/bots/download_android_sdk.sh) `dev/bots/download_android_sdk.sh` in this repo:

```
yes | $ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager --licenses
$ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager tools
$ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager platform-tools
$ANDROID_SDK_ROOT/cmdline-tools/tools/bin/sdkmanager  "platforms;android-28" \
    "build-tools;28.0.3" \
    "platforms;android-27" \
    "build-tools;27.0.3" \
    "extras;google;m2repository" \
    "extras;android;m2repository"
```
where for me `ANDROID_SDK_ROOT` is `$HOME/Android`. As far as I can tell, all goes well with these. 

4. run `<path-to-flutter> doctor -v`; this finds `SDK` all right, but cries about licenses (see the output below). I am instructed to run `doctor --android-licenses`. 

5. Finally, this last command produces an error:

```
$ export ANDROID_HOME=~/Android && ~/repos/flutter/bin/flutter doctor --android-licenses
---
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:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 5 more
```


## Logs

<!--
      Include the full logs of the commands you are running between the lines
      with the backticks below. If you are running any "flutter" commands,
      please include the output of running them with "--verbose"; for example,
      the output of running "flutter --verbose create foo".
-->

```
```

Output to `<path-to-flutter> doctor -v`:

```
[✓] Flutter (Channel master, 1.21.0-6.0.pre.180, on Linux, locale en_US.UTF-8)
    • Flutter version 1.21.0-6.0.pre.180 at $HOME/repos/flutter
    • Framework revision 428be90768 (3 hours ago), 2020-08-04 14:31:05 -0700
    • Engine revision 033dd45607
    • Dart version 2.10.0 (build 2.10.0-2.0.dev 0f0e04ec3a)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at $HOME/Android
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = $HOME/Android
    • ANDROID_SDK_ROOT = $HOME/Android
    • Java binary at: /usr/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.
```