I'm trying to write a Flutter plugin that relies on a third-party library on Android.
The dependency has a build.gradle
file, I've got the source and I can build an aar
file from the command line using gradle build
.
I tried to add the dependency using Android Studio but it ended up in the my_plugin/example/android
directory and no matter how many times did I try to move it to the plugin's my_plugin/android
directory, I always failed.
The reason why this is an issue is that even though the example app can be built and run, I cannot use the plugin in other Flutter apps (which is the whole reason one would create a Flutter plugin).
How do I need to add a local library module (source code) or the aar
(that I can build any time) to the Flutter plugin's Android implementation?
Add to Android applications Auto-build and import the Flutter module by adding a Flutter SDK hook to your Gradle script. Build your Flutter module into a generic Android Archive (AAR) for integration into your own build system and for better Jetifier interoperability with AndroidX.
I am new in flutter and I want to add Fast Android networking library to flutter dependencies and I don't know how to add, anyone, help me, please. You can go to the pubspec. yaml file and add dependencies ,under dependencies and then packages get will do the work. or you can run flutter pub get in the terminal.
Add your AAR or JAR as a dependency Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your .
well, you were halfway through the process...
android
folder.settings.gradle
in android
folder and to the beginning of the file add this line:
include ':android/library_folder_name'
build.gradle
in android
folder and in the dependencies block add this line:
implementation fileTree(dir: 'library_folder_name', include: ['*.aar', '*.jar'], exclude: [])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With