1

I would like to add .aar file to my java module (sub project).i have added this in my gradle still get error as "Could not find filename"

 flatDir {
        dirs 'src/main/libs'
    }

 implementation fileTree(include: ['*.jar', '*.aar'], dir: 'src/main/libs')
 implementation (name: '**filename**', ext: 'aar')
ravi sen
  • 11
  • 1
  • 2
  • Does this answer your question? [How to manually include external aar package using new Gradle Android Build System](https://stackoverflow.com/questions/16682847/how-to-manually-include-external-aar-package-using-new-gradle-android-build-syst) – Kaushik Burkule Nov 25 '19 at 12:18

2 Answers2

2

You should follow below steps in Android Studio:

  1. Right click on your project and select "Open Module Settings".
  2. Click the "+" button in the top left corner of window to add a new module.
  3. Select "Import .JAR or .AAR Package" and click the "Next" button.
  4. Find the AAR file using the ellipsis button "..." beside the "File name" field.
  5. Keep the app's module selected and click on the Dependencies pane to add the new module as a dependency.
  6. Use the "+" button of the dependencies screen and select "Module dependency".
  7. Select the module and click "OK".

Then Clean, Rebuild and Make your project.

kaushal malvi
  • 72
  • 1
  • 6
2

For Android Studio 4.2 and above, please use these instructions from the documentation https://developer.android.com/studio/projects/android-library#psd-add-aar-jar-dependency

Denny
  • 991
  • 12
  • 20