I am working in a flutter plugin and want to import aar project in android part of the plugin. I have tried opening the android project and importing the aar project by importing the module, including it in setting.gradle and adding it in dependency of build.grade (like any other native android project). However, when I run the flutter project, the aar project is not found. enter image description here. Anybody with the fix ?
CodePudding user response:
Put your .aar in Android/app/libs In Android/app/build.gradle you import the aar :
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/myaarlibr.aar')
}
After this your .aar is ready for use
CodePudding user response:
I finally found the answer.
- create a lib folder in directory where the build.gradle is and place your aar file in the folder.
- Then add flatDir { dirs 'lib'} in your rootProject.allprojects
- Then add dependency in the build. file in the dependencies section as:
api(name: 'your_aar_file_name', ext: 'aar')
Note: Make sure to add all the dependencies included in gradle.build file (if your aar file depends on any gradle.build file of its own) in the dependencies section of your application build.gradle file . This was the main issue in my case.