I\'ve create a flutter plugin with:
flutter create --template plugin flutter_plugin
I\'ve put my aar file inside flutter_plugin/android/src
My solution to add local .aar depencies to a flutter plugin is as follows (based on the instructions here How to add .aar dependency in library module?):
1) create a libs folder in your android plugin source code (/android/libs) (on top level of your plugin, not in the example project)
2) add your .aar files in this folder
3) add your .aar dependencies to your plugins build.gradle file (/android/build.gradle) e.g.
dependencies {
...
implementation (name: 'myFirstDependency', ext: 'aar')
implementation (name: 'myOtherDependency', ext: 'aar')
}
3) in order for gradle to be able to find these dependencies you need to instruct gradle to search in the libs folder inside of the plugin. Therefore add the following to your plugins build.gradle (/android/build.gradle, same as for your dependencies) under rootProject.allprojects repositories section. (NOTE: there is also a buildscripts a repositories section which you should not change for this).
rootProject.allprojects {
repositories {
google()
jcenter()
//Add this below is whatever your plugin is called eg. url_launcher
flatDir {
dirs project(':').file('libs')
// e.g. dirs project(':url_launcher').file('libs') - don't miss the ':'
}
}
}
With that, you don't have the .aar library dependencies directly in your plugin.