无法完成操作。找不到 Java 运行时。请访问 http://www.java.com 以获取有关安装 Java 的信息

我无法在Android模拟器或Android手机上运行flutter应用程序。我在m1 mac上安装了最近发布的用于arm-mac平台的Android工作室。请回答我在这里做错了什么,还是发布本身的问题。

调试控制台输出:

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Exception: Gradle task assembleDebug failed with exit code 1

颤振医生-v输出:

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-arm, locale en-IN)
    • Flutter version 2.2.1 at /Users/hmnth/FlutterDev/flutter
    • Framework revision 02c026b03c (10 weeks ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/hmnth/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /usr/bin/java
    ✗ Could not determine java version

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      						

答案 1

Go to Applications then right click on Android Studio, then choose "Show Package Contents", create a new folder inside jre named jdk and copy the contents of jre to jdk

This is the link for the fix https://github.com/flutter/flutter/issues/76215#issuecomment-864407892


答案 2

I was able to fix my issues by doing the following, I sync my project with Gradle files

I downloaded Java 8 (but I don't think this guy did the work)


推荐