AndroidStudio 運(yùn)行Flutter項(xiàng)目是通過 Xcode 構(gòu)建項(xiàng)目的,所以真機(jī)遇到問題烤礁,可以先使用Xcode打開對(duì)應(yīng)iOS項(xiàng)目進(jìn)行調(diào)試給出的錯(cuò)誤信息也比較準(zhǔn)確讼积,編譯沒問題后用AndroidStudio真機(jī)運(yùn)行項(xiàng)目。
下面總結(jié)了幾個(gè)筆者在Flutter真機(jī)調(diào)試時(shí)錯(cuò)誤處理:
問題1:運(yùn)行FlutterSDK低版本項(xiàng)目的建議
問題2:Xcode iOS Flutter真機(jī)調(diào)試錯(cuò)誤 It appears that your application still contains the default signing identifier
問題3:Xcode iOS Flutter真機(jī)調(diào)試錯(cuò)誤: Could not build the precompiled application for the device
問題4:Xcode iOS Flutter真機(jī)調(diào)試錯(cuò)誤:Could not install build/ios/iphoneos/Runner.app on
問題1:運(yùn)行FlutterSDK低版本項(xiàng)目的建議
由于FlutterSDK更新比較頻繁脚仔,有時(shí)下載一個(gè)項(xiàng)目后會(huì)發(fā)現(xiàn)勤众,報(bào)各種bug,各種問題鲤脏,下面總結(jié)下處理步驟:
1> 找到pubspec.yaml 文件们颜,執(zhí)行 flutter get pub
安裝項(xiàng)目所需插件。
2> 確定低版本項(xiàng)目的環(huán)境配置是否和當(dāng)前電腦環(huán)境一致猎醇,下面給出一個(gè)筆者下載的低版本項(xiàng)目所需運(yùn)行環(huán)境:
Flutter SDK (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.13.6 17G2112, locale zh-Hans-CN窥突, Dart SDK : 2.5.0)
如果報(bào)一些的第三方庫(kù)方法或者參數(shù)錯(cuò)誤,查看電腦配置環(huán)境Flutter SDK是否高于v1.5.4硫嘶。筆者當(dāng)時(shí)配置Flutter SDK版本為1.7.2阻问,找到Flutter SDK所在文件夾,git reset --hard commit_id
回退到指定版本v1.5.4后解決沦疾。
Flutter官網(wǎng)獲取commitId
Flutter github項(xiàng)目下獲取commitId
問題2:Xcode iOS Flutter真機(jī)調(diào)試錯(cuò)誤 It appears that your application still contains the default signing identifier
錯(cuò)誤信息:
Could not build the precompiled application for the device.
It appears that your application still contains the default signing identifier.
Try replacing ‘com.example‘ with your signing id in Xcode:
open ios/Runner.xcworkspace
Error launching application on iPhone.
原因:真機(jī)調(diào)試時(shí)候称近,應(yīng)用bundle Id和蘋果證書上注冊(cè)的不一致第队,或者沒有安裝蘋果開發(fā)者證書。
解決:打開xcode修改bundle Id刨秆。選擇有效期內(nèi)的蘋果開發(fā)者證書凳谦。注意xcode版本和編譯系統(tǒng)版本要和iphone手機(jī)系統(tǒng)搭配。
問題3:Xcode iOS Flutter真機(jī)調(diào)試錯(cuò)誤: Could not build the precompiled application for the device
錯(cuò)誤信息:
Could not build the precompiled application for the device.
Error launching application on iPhone8p.
解決:
-
首先Xcode打開對(duì)應(yīng)iOS項(xiàng)目衡未,確定singing配置和bundle Id有效尸执,如下圖:
singing配置 然后打開Xcode,F(xiàn)ile->Workspace Settings-> 找到Build System 選項(xiàng)修改為: Legacy Build System缓醋。
- 編譯沒問題后Xcode真機(jī)運(yùn)行如失,如果有下面彈窗提示,需要真機(jī)需要信任運(yùn)行app 改衩,真機(jī)上操作步驟: 手機(jī)設(shè)置->通用->設(shè)備管理->找到運(yùn)行app設(shè)置信任`岖常。
- 修改后重新真機(jī)運(yùn)行AndroidStudio驯镊。
問題4:Xcode iOS Flutter真機(jī)調(diào)試錯(cuò)誤:Could not install build/ios/iphoneos/Runner.app on
錯(cuò)誤信息:
Could not install build/ios/iphoneos/Runner.app on xxxxxx.
Try launching Xcode and selecting "Product > Run" to fix the problem:
open ios/Runner.xcworkspace
Error launching application on iPhonesk8p.
原因: 真機(jī)上沒有信任運(yùn)行的app!
解決: 手機(jī)設(shè)置->通用->設(shè)備管理->找到運(yùn)行app設(shè)置信任