Android 项目集成flutter有两种方式,一种方式以前已经整理过 melissa-l.cn/android-xia…,今天咱们来看看经过aar 的方式 集成flutter,并使用flutter_boost,为何要使用我就再也不赘述,你要是想本身写路由插件也行,个人原则是有肩膀就站java
先说一下本地的版本android
Flutter 1.9.1+hotfix.6 (是目前的stable版,你要正式开发最好都用稳定版)
Dart 2.5.0复制代码
flutter 的代码在 github.com/melissa-l/f… clone到本地后,直接跑 flutter build aar
而后根据答应出的路径找到 build/host/outputs/repo/com
这个时候你会看到 com
文件夹下有两个文件夹 idlefish
和 example
:git
idlefish
: 这个是咱们flutter_boost 的插件包,通常的插件包都会打包在你本地的项目里,可是这里咱们 pubspec.yaml
中的flutter_boost
是 从github 分支上下载的 , 因此会不单独打包, 一路点下去就会发现 1.0
这个文件夹,咱们要用的是 flutter_boost_release-1.0.aar
pubspec.yaml
最下面 module 中定义的 androidPackage 生成的目录,一样的一路点下去,找到 1.0
中的flutter_release-1.0.aar
至此,咱们 flutter 的部分就结束了, 接下来就是客户端中的配置部分。
先把上面的两个aar,移动或复制到 安卓项目的 app/libs
下,而后再 app/build.gradle
中加入github
dependencies {
......
implementation files('libs/flutter_release-1.0.aar')
implementation files('libs/flutter_boost_release-1.0.aar')
implementation "androidx.lifecycle:lifecycle-common-java8:$lifeCycle"
}复制代码
而后,在 app/src/main/AndroidManifest.xml 中 手动加入一个activity,这个就是flutter的activity:bash
<activity
android:name="com.idlefish.flutterboost.containers.NewBoostFlutterActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:theme="@style/Theme.AppCompat"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/page_loading" />
</activity>复制代码
而后其余的文件, 新增java、xml 代码就跟 github.com/alibaba/flu… 同样配置。app