1

根据文档https://flutter.dev/docs/development/add-to-app/android/plugin-setup#b-plugins-needing-project-edits

For advanced users, if more modularity is needed and you must not leak knowledge of your Flutter module’s dependencies into your outer host app, you can rewrap and repackage your Flutter module’s Gradle library inside another native Android Gradle library that depends on the Flutter module’s Gradle library. You can make your Android specific changes such as editing the AndroidManifest.xml, Gradle files or adding more Java files in that wrapper library.

所以我们可以为 Flutter 模块制作 Android 原生的封装库,以便在外部项目中导入这个库,而不是直接添加 Flutter 模块。

我的问题是我们如何在 Android 库中添加 Flutter 模块

在文档中,它给出了更新 settings.gradle 这个

// Include the host app project.
include ':app'                                    // assumed existing content
setBinding(new Binding([gradle: this]))                                // new
evaluate(new File(                                                     // new
  settingsDir.parentFile,                                              // new
  'my_flutter/.android/include_flutter.groovy'                         // new
)) 

但是我们不能将 settings.gradle 添加到 android 库模块中。它只能添加到根项目中。

任何人都可以分享 git repo 以在 Android 库中包含颤振模块吗?

我做了什么:

  1. 创建一个新的安卓项目
  2. 添加了一个新模块 mylibrary say
  3. 克隆 mylibrary 中的颤振模块目录
  4. 添加implementation project(':flutter')在 :mylibrary build.gradle

现在,当我生成 aar 时,即使根项目运行良好,它也不包含颤振模块

4

0 回答 0