1、flutter模块不识别或者不显示flutter蓝色图标
在工程下的settings.gradle中添加模块配置:
include ':flutter_project'
project(':flutter_project').projectDir = new File('./flutter_project')
2、遇到AS上flutter attach和hotload按钮不可点击的情况
点击Edit Confirations,新增一个flutter配置,Dart entrypoint选择flutter模块中的main.dart
3、关于flutter作为模块debug调试的问题
解决问题2之后,app主模块run起来之后,点击AS菜单栏中的红色stop按钮,杀掉进程,然后点击flutter attach按钮,最后再点击手机里APP图标启动应用,切记不可以用AS的run启动APP
这个时候flutter代码就应该可以调试和热加载了
4、flutter作为工程模块,启动白屏问题
要在主模块(一般是app模块)的AndroidManifest.xml里找到继承了FlutterActivity的那个Activity,对它进行如下操作:配置theme和meta-data
<activity
android:name=".ui.MainActivity"
android:enabled="true"
android:exported="true"
android:launchMode="singleTask"
android:resizeableActivity="true"
android:screenOrientation="portrait"
android:stateNotNeeded="true"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustPan">
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
</activity>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowFullscreen">true</item>
</style>
<?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="fill"
android:src="@drawable/play_bg" />
</item>
</layer-list>