简体   繁体   English

如何从 Android Studio 在 Windows 10 上运行 Build runner

[英]How to run Build runner on Windows 10 from Android Studio

I'm following through Google's code labs for Flutter Googlemaps,我正在关注 Google 的 Flutter Googlemaps 代码实验室,

https://codelabs.developers.google.com/codelabs/google-maps-in-flutter/#5 https://codelabs.developers.google.com/codelabs/google-maps-in-flutter/#5

G Labs says G 实验室 说

Once you've added this code, your IDE (if you are using one) should display some red squiggles, as it references a nonexistent sibling file, locations.g.dart.添加此代码后,您的 IDE(如果您正在使用)应该显示一些红色波浪线,因为它引用了一个不存在的同级文件,locations.g.dart。 This generated file converts between untyped JSON structures and named objects.这个生成的文件在无类型 JSON 结构和命名对象之间进行转换。 Create it by running the build_runner:通过运行 build_runner 创建它:

Build runner is supposed to output this: Build runner 应该输出这个:

$ flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 291ms

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 65ms

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 595ms

[INFO] Running build...
[INFO] 1.2s elapsed, 0/1 actions completed.
[INFO] Running build completed, took 1.2s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 27ms

[INFO] Succeeded after 1.2s with 1 outputs (1 actions)

$
  • I've added the 'build_runner: ^1.2.7' dev_dependency to my .yaml file, done some googling around, tried various commands in Android Studio Terminal, none of which were recognised.我已将 'build_runner: ^1.2.7' dev_dependency 添加到我的 .yaml 文件中,做了一些谷歌搜索,在 Android Studio Terminal 中尝试了各种命令,但没有一个被识别。
  • I tried changing the Terminal directory from my app directory to the C:/flutter directory, but the commands still weren't recognised.我尝试将终端目录从我的应用程序目录更改为 C:/flutter 目录,但仍然无法识别命令。

I've no clue how to do this.我不知道如何做到这一点。 In their print out of their console the cursor carat is a $, which doesn't appear for Android Studio console on windows 10, so.... confusion.在他们打印出来的控制台中,光标克拉是一个 $,它不会出现在 Windows 10 上的 Android Studio 控制台中,所以......混乱。

Here's the .yaml file as requested这是请求的 .yaml 文件

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  google_maps_flutter: ^0.5.11
  http: ^0.12.0+1
  json_serializable: ^2.0.2


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.3

dev_dependencies:
  pedantic: ^1.4.0
  build_runner: ^1.2.7
  flutter_test:
    sdk: flutter

@i6x86 correctly diagnosed the problem, I hadn't set Flutter up fully. @i6x86 正确诊断了问题,我还没有完全设置 Flutter。 I followed the instructions here: flutter.dev/docs/get-started/install/windows#update-your-path我按照这里的说明操作: flutter.dev/docs/get-started/install/windows#update-your-path

Rebooted Android Studio and voila, it solved the problem.重新启动 Android Studio 和瞧,它解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM