1 去除Debug 標(biāo)簽
問(wèn)題:默認(rèn)創(chuàng)建的Flutter應(yīng)用運(yùn)行時(shí)烦绳,屏幕右上角會(huì)帶Debug標(biāo)簽
解決:在MyApp的build方法中設(shè)置debugShowCheckedModeBanner
屬性為false
异希。
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
...
);
}
}
...
2 運(yùn)行程序報(bào)錯(cuò)Error connection to the service protocol
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
......
Error connecting to the service protocol: failed to connect to http://127.0.0.1:52037/VrXq5vhCjj4=/
解決:
- 第一種情況熏纯,Android模擬器
堅(jiān)持自己的模擬器所使用的Android SDK版本芹血,然后通過(guò)Tools -> SDKManager 下載匹配的platform版本。 - 第二種情況男公,iOS真機(jī)耙考。 iOS13.3.1不支持真機(jī)調(diào)試,但是不影響Release顺少。所以如果是這個(gè)版本的真機(jī)沒(méi)法進(jìn)行調(diào)試朋其。
3 Android toolchain 報(bào)錯(cuò)
$ flutter doctor
...
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
? Android SDK at /Users/jiafujia/Library/Android/sdk
? Android NDK location not configured (optional; useful for native profiling support)
? Platform android-28, build-tools 28.0.3
? Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
? Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
? Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit https://flutter.dev/setup/#android-setup for detailed instructions.
...
解決: 通過(guò)flutter doctor --android-licenses
查看原因,根據(jù)提示信息解決脆炎。有可
$ flutter doctor --android-licenses
4 iOS無(wú)法真機(jī)測(cè)試
$ flutter upgrade
$ flutter clean
$ flutter build ios
5 iOS模擬器測(cè)試報(bào)錯(cuò)
Building for iOS Simulator, but the linked and embedded framework 'App.framework' was built for iOS. (in target 'Runner' from project 'Runner')
這是因?yàn)檎鏅C(jī)測(cè)試之后梅猿,會(huì)生成 ios -> Flutter -> App.framework, 而在iOS中構(gòu)建的真機(jī)動(dòng)態(tài)庫(kù)和模擬器動(dòng)態(tài)庫(kù)是不一樣的。因此我們無(wú)法同時(shí)在iOS模擬器和真機(jī)測(cè)試秒裕。
在切換iOS真機(jī)和模擬器時(shí)袱蚓,我們需要先手動(dòng)刪除 App.framework這個(gè)文件夾,然后重新build几蜻,如果是真機(jī)測(cè)試喇潘,build方式 flutter build ios
. 如果是模擬器如下:
$ flutter devices
1 connected device:
iPhone 11 Pro Max ? F7B8BFE6-0E23-4777-826F-A132D8A155C2 ? ios ? com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
$ flutter run -d F7B
這樣就可以在模擬器上進(jìn)行測(cè)試了。
持續(xù)更新中...