簡體   English   中英

如何從 Android Studio 在 Windows 10 上運行 Build runner

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

我正在關注 Google 的 Flutter Googlemaps 代碼實驗室,

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

G 實驗室 說

添加此代碼后,您的 IDE(如果您正在使用)應該顯示一些紅色波浪線,因為它引用了一個不存在的同級文件,locations.g.dart。 這個生成的文件在無類型 JSON 結構和命名對象之間進行轉換。 通過運行 build_runner 創建它:

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)

$
  • 我已將 'build_runner: ^1.2.7' dev_dependency 添加到我的 .yaml 文件中,做了一些谷歌搜索,在 Android Studio Terminal 中嘗試了各種命令,但沒有一個被識別。
  • 我嘗試將終端目錄從我的應用程序目錄更改為 C:/flutter 目錄,但仍然無法識別命令。

我不知道如何做到這一點。 在他們打印出來的控制台中,光標克拉是一個 $,它不會出現在 Windows 10 上的 Android Studio 控制台中,所以......混亂。

這是請求的 .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 正確診斷了問題,我還沒有完全設置 Flutter。 我按照這里的說明操作: flutter.dev/docs/get-started/install/windows#update-your-path

重新啟動 Android Studio 和瞧,它解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM