Error Building Android Library: Direct Local .Aar File Dependencies Are Not Supported

Error building Android library: Direct local .aar file dependencies are not supported

I recently encountered the same issue, the fix was to remove the library from libs/ and import it using File -> New -> New Module -> Import .JAR/.AAR Package, then referencing it in the library module build.gradle file:

dependencies {
implementation project(":imported_aar_module")
}

If you are on a newer Android Studio version (4.0.0+), this option is not available. Instead you have to do it manually.

  1. Create a new directory and put the following content into the build.gradle file withing the new directory:
configurations.maybeCreate("default")
artifacts.add("default", file('[nameOfTheAar].aar'))

  1. Place the aar into this new directoy. Next to the build.gradle file.
  2. Add the new created Gradle project to the settings.gradle file:
include(":pathToTheCreatedDirectory")

  1. Include the project in your library where you want to use the aar:
implementation project(":pathToTheCreatedDirectory", configuration = "default")

how to integrate an android .aar library file into a flutter project

First creat a libs folder in android root folder then adding your .aar file to libs(in your case liblibrary) folder in android root folder, add this in android build.gradle:

allprojects {
repositories {
google()
jcenter()
flatDir {
dirs '../libs' // in your case liblibrary
}
}
}

then in app build.gradle add this:

dependencies {
...
implementation(name:'your_file_name', ext:'aar')
}

then sync your gradle and you are good to go.



Related Topics



Leave a reply



Submit