According to the docs 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.
So we can make Android native wrapper library for flutter module so as to make this library import in external projects rather than directly adding Flutter module.
My question is how we can add Flutter module inside Android Library
In docs its given to update settings.gradle with this
// 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
))
But we cant add settings.gradle to android library module. It can be only added to root projects.
Can anyone share git repo for having flutter module inside Android library?
What i did:
- Create a new Android project
- Added a new module mylibrary say
- Clone flutter module dir inside mylibrary
- Added
implementation project(':flutter')
in :mylibrary build.gradle
Now when i generate aar it doesnt include flutter module's even though the root project runs fine