记坑:flutter doctor --android-licenses 【报错】Exception in thread “main“ Android sdkmanager tool was foun

配置flutter时,在Flutter console终端界面,因为SDK版本问题,一直报错,据网友说要安装JDK 8, 之后又是安装JDK 8, 又是修改环境变量,折腾好半天。因为在网上没看到相应的报错,记录一下

记坑:flutter doctor --android-licenses 【报错】Exception in thread “main“ Android sdkmanager tool was foun_第1张图片

flutter doctor --android-licenses一直有错误,错误如下:

C:\Users\123>flutter doctor --android-licenses
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
java.lang.UnsupportedClassVersionError: com/android/prefs/AndroidLocationsProvider has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" Android sdkmanager tool was found, but failed to run
(C:\Users\123\AppData\Local\Android\sdk\cmdline-tools\latest\bin\sdkmanager.bat): "exited code 1".
Try re-installing or updating your Android SDK,
visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.

记坑:flutter doctor --android-licenses 【报错】Exception in thread “main“ Android sdkmanager tool was foun_第2张图片 

 在报错信息的末尾,我看到有 "Android sdkmanager tool was found, but failed to run",想到在Android Studio里的SDK 配置好像不太一致:在SDK TOOLS处,我原先勾选的时Android SDK Command-line Tools(latest) , 版本version是9.0,但我安装的是JDK 8 ,我想会不会是SDK TOOLS要选择版本8.0?就试了一下,本想到就解决了。

解决方法:将Android Studio ->Android SDK ->SDK Tools处,勾选版本为8.0 的Android SDK Command-line Tools,并取消勾选版本为9.0 的Android SDK Command-line Tools.

记坑:flutter doctor --android-licenses 【报错】Exception in thread “main“ Android sdkmanager tool was foun_第3张图片我是因为这个操作解决的报错,发布出来做个参考吧。

你可能感兴趣的:(android,flutter,android,studio)