1. mac 无法打开“idevice_id”。
解决办法:系统偏好设置-安全性与隐私-信任。
2. Could not find an option named "androidx"
AS 创建Flutter项目报上面错误信息,可能因为flutter sdk 版本过低。
FlutterSDK下载地址
https://flutter.dev/docs/development/tools/sdk/releases?tab=macos
3. Mac环境下Android Studio 无法连接iOS模拟器
在mac环境下用Android Studio 写Flutter,可以启动iOS 模拟器,但是在设备列表里找不到模拟器时
打开终端并输入下面命令:
sudo xcode-select --switch/Applications/Xcode.app/Contents/Developer
之后回车,输入本机密码,就可以了
4. Your app isn’t using AndroidX
android gradle.properties下添加
android.enableJetifier=true
android.useAndroidX=true
5. bottom overflowed by 94 pixels
Scaffold下添加如下配置:resizeToAvoidBottomInset: false
原因:防止软键盘弹出时遮挡页面的东西。当设置为 true 的时候,软键盘弹出页面会自动调整尺寸避免遮挡; 当为 false 的时候则软键盘弹出不会自动调整尺寸。该属性值默认为 true。
6. 启动黑屏
Flutter项目启动过程:
1、显示android启动项activity
2、flutter启动项activity
3、进入flutter项目的第一个页面
黑屏对应的是flutter启动项activity
解决方案:
AndroidManifest.xml中目标activity下加入
<application
android:name="io.flutter.app.FlutterApplication"
android:label="swift_rabbit"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!--Flutter 闪屏页-->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background" />
<!--闪屏页结束后的Theme-->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" />
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/normal_background</item>
</style>
</resources>
normal_background.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="@mipmap/naruto" />
</item>
</layer-list>
7. Flutter: Exception in thread “main” java.util.zip.ZipException:
error in opening zip file
修改android gradle版本build.gradle / gradle-wrapper.properties