發表日期:2018-11 文章編輯:小燈 瀏覽次數:2134
bash, mkdir, rm, git, curl, unzip
Documents
目錄下unzip ~/Documents/下載下來的包-beta.zip
flutter
命令解壓縮后,不要急著進入 flutter
文件夾,還停留在 Documents
文件目錄下(或者執行 cd ~/Documents
切到這個目錄),然后執行下面的命令:
$ export PATH=$PATH:`pwd`/flutter/bin
有了這一步,可以避免這個問題: command not found: flutter
執行下面命令來檢測本機環境依賴
$ flutter doctor
輸出如下:
[?] Flutter (Channel beta, v0.11.3, on Mac OS X 10.14 18A391, locale zh-Hans-CN) [?] Android toolchain - develop for Android devices ? Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.io/setup/#android-setup for detailed instructions). If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location. You may also want to add it to your PATH environment variable.[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1) ? libimobiledevice and ideviceinstaller are not installed. To install with Brew, run: brew update brew install --HEAD usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice brew install ideviceinstaller ? ios-deploy not installed. To install with Brew: brew install ios-deploy [!] Android Studio (not installed) [?] VS Code (version 1.29.0) [?] Connected device (2 available)
顯示叉號 ?
的,表示相應的工具沒有安裝。其中比較重要的兩大開發工具是:Xcode
和 Android Statudio
。
如果這兩個沒有安裝,需要根據你的開發者身份,安裝對應的開發工具
Xcode
,最好是最新版本的Xcode
,同意它的 license
等(適用于新裝Xcode
)Xcode command-line
指定要使用的 Xcode
版本:$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
iPhone 5s
或之后版本的模擬器,然后執行:$ open -a Simulator
$ brew update $ brew install --HEAD usbmuxd $ brew link usbmuxd $ brew install --HEAD libimobiledevice $ brew install ideviceinstaller ios-deploy cocoapods $ pod setup
進入某個 flutter
項目目錄
$ cd ~/Documents/flutter/examples/hello_world
執行命令,安裝 hello_world
到模擬器:
$ flutter run
運行一會后,模擬器已經安裝了hello_world
,但并沒有launch
。也許會報錯:
ProcessException: Process "/usr/bin/xcrun" exited abnormally: "io.flutter.examples.hello-world": -1An error was encountered processing the command (domain=FBSOpenApplicationServiceErrorDomain, code=1): The request to open ""io.flutter.examples.hello-world"" failed. The request was denied by service delegate (SBMainWorkspace) for reason: NotFound ("Application ""io.flutter.examples.hello-world"" is unknown to FrontBoard"). Underlying error (domain=FBSOpenApplicationErrorDomain, code=4): The operation couldn’t be completed. Application ""io.flutter.examples.hello-world"" is unknown to FrontBoard. Application ""io.flutter.examples.hello-world"" is unknown to FrontBoard. Command: /usr/bin/xcrun simctl launch 4B7B9269-47FA-47B6-8096-17AB675A3E4F "io.flutter.examples.hello-world" --enable-dart-profiling --enable-checked-mode --observatory-port=0 Error launching application on iPhone 5s.
這里暴露出了 flutter
的另一個問題:
根據 $(PRODUCT_BUNDLE_IDENTIFIER)
不能成功的launch
模擬器
解決方法是:
Xcode
打開 hello-world
項目info.plist
Bundle identifier
的值為 io.flutter.examples.hello-world
再次執行 flutter run
. 模擬器成功 launch
.
Android Studio
,執行 “Android Studio Setup Wizard”
Developer options
和 USB debugging
. 這個文檔有詳細說明 Android documentation flutter devices
flutter run
啟用 VM acceleration .
Launch Android Studio ->Tools -> Android -> AVD Manager
并選擇 Create Virtual Device
.
選擇一個設備并選擇 Next
為你要模擬的 Android
版本選擇一個或多個系統鏡像,然后選擇 Next
. 建議使用 x86
或 x86_64
鏡像 .
在 Emulated Performance下
, 選擇 Hardware - GLES 2.0
啟用 硬件加速.
驗證AVD配置是否正確,選擇 Finish
。上述步驟的詳細信息,請參閱 Managing AVDs.
在 Android Virtual Device Manager
中, 點擊 Run
啟動模擬器
運行 flutter run
. 可以看到連接的設備名稱是 Android SDK built for <x86or其他型號>
至此,Flutter
的環境部署就結束了。
日期:2018-10 瀏覽次數:7525
日期:2018-12 瀏覽次數:4598
日期:2018-07 瀏覽次數:5115
日期:2018-12 瀏覽次數:4402
日期:2018-09 瀏覽次數:5756
日期:2018-12 瀏覽次數:10181
日期:2018-11 瀏覽次數:5091
日期:2018-07 瀏覽次數:4845
日期:2018-05 瀏覽次數:5098
日期:2018-12 瀏覽次數:4562
日期:2018-10 瀏覽次數:5377
日期:2018-12 瀏覽次數:6438
日期:2018-11 瀏覽次數:4705
日期:2018-08 瀏覽次數:4850
日期:2018-11 瀏覽次數:12938
日期:2018-09 瀏覽次數:5858
日期:2018-12 瀏覽次數:5084
日期:2018-10 瀏覽次數:4423
日期:2018-11 瀏覽次數:4769
日期:2018-12 瀏覽次數:6299
日期:2018-06 瀏覽次數:4249
日期:2018-08 瀏覽次數:5697
日期:2018-10 瀏覽次數:4681
日期:2018-12 瀏覽次數:4792
日期:2018-07 瀏覽次數:4614
日期:2018-12 瀏覽次數:4783
日期:2018-06 瀏覽次數:4623
日期:2018-11 瀏覽次數:4603
日期:2018-12 瀏覽次數:4526
日期:2018-12 瀏覽次數:5507
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.