在 intellij ide 中获取异常,flutter 演示应用程序 hello_services
Getting exception in intellij ide for, flutter demo app hello_services
Exception from flutter run: Exception: Unable to locate Gradle. Please configure the path to Gradle using `flutter config --gradle-dir`.
package:flutter_tools/src/base/common.dart 31 throwToolExit
package:flutter_tools/src/android/gradle.dart 115 buildGradleProject.<async>
dart:async/future.dart 184 Future.Future.microtask.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
dart:async/zone.dart 1146 _rootRun
dart:async/zone.dart 1026 _CustomZone.run
dart:async/zone.dart 924 _CustomZone.runGuarded
dart:async/zone.dart 951 _CustomZone.bindCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
dart:async/zone.dart 1150 _rootRun
dart:async/zone.dart 1026 _CustomZone.run
dart:async/zone.dart 924 _CustomZone.runGuarded
dart:async/zone.dart 951 _CustomZone.bindCallback.<fn>
dart:async/schedule_microtask.dart 41 _microtaskLoop
dart:async/schedule_microtask.dart 50 _startMicrotaskLoop
dart:isolate-patch/isolate_patch.dart 96 _runPendingImmediateCallback
dart:isolate-patch/isolate_patch.dart 149 _RawReceivePortImpl._handleMessage
===== asynchronous gap ===========================
如果我在终端运行 flutter config,终端会抛出flutter command not found异常
这是试图找到 gradle 的代码:
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/gradle.dart#L37
flutter
命令位于您下载的flutter SDK的bin
目录中。我们的设置文档中介绍了将其添加到您的路径中:https://flutter.io/setup/#get-the-flutter-sdk
您可以使用命令的参数或全局使用带有 --gradle-dir
或 --android-studio-dir
标志的 flutter config
来指定 gradle 二进制文件的位置。
正如您在链接代码中看到的,我们知道如何在某些默认位置找到 gradle,例如在 /Applications/Android Studio.app
内部或通过读取您的路径变量。我们可能可以添加更多默认位置。
如果您认为您的 Android SDK 安装在我们没有检查的默认位置,请在 https://github.com/flutter/flutter/issues/new 提交错误,我们很乐意修复。
Exception from flutter run: Exception: Unable to locate Gradle. Please configure the path to Gradle using `flutter config --gradle-dir`.
package:flutter_tools/src/base/common.dart 31 throwToolExit
package:flutter_tools/src/android/gradle.dart 115 buildGradleProject.<async>
dart:async/future.dart 184 Future.Future.microtask.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
dart:async/zone.dart 1146 _rootRun
dart:async/zone.dart 1026 _CustomZone.run
dart:async/zone.dart 924 _CustomZone.runGuarded
dart:async/zone.dart 951 _CustomZone.bindCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
package:stack_trace/src/stack_zone_specification.dart 185 StackZoneSpecification._run
package:stack_trace/src/stack_zone_specification.dart 97 StackZoneSpecification._registerCallback.<fn>
dart:async/zone.dart 1150 _rootRun
dart:async/zone.dart 1026 _CustomZone.run
dart:async/zone.dart 924 _CustomZone.runGuarded
dart:async/zone.dart 951 _CustomZone.bindCallback.<fn>
dart:async/schedule_microtask.dart 41 _microtaskLoop
dart:async/schedule_microtask.dart 50 _startMicrotaskLoop
dart:isolate-patch/isolate_patch.dart 96 _runPendingImmediateCallback
dart:isolate-patch/isolate_patch.dart 149 _RawReceivePortImpl._handleMessage
===== asynchronous gap ===========================
如果我在终端运行 flutter config,终端会抛出flutter command not found异常
这是试图找到 gradle 的代码: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/android/gradle.dart#L37
flutter
命令位于您下载的flutter SDK的bin
目录中。我们的设置文档中介绍了将其添加到您的路径中:https://flutter.io/setup/#get-the-flutter-sdk
您可以使用命令的参数或全局使用带有 --gradle-dir
或 --android-studio-dir
标志的 flutter config
来指定 gradle 二进制文件的位置。
正如您在链接代码中看到的,我们知道如何在某些默认位置找到 gradle,例如在 /Applications/Android Studio.app
内部或通过读取您的路径变量。我们可能可以添加更多默认位置。
如果您认为您的 Android SDK 安装在我们没有检查的默认位置,请在 https://github.com/flutter/flutter/issues/new 提交错误,我们很乐意修复。