We recently upgraded to Android Gradle Plugin 4.0.0-beta03. We are now seeing this error when building one of our library modules
$ ./gradlew library_module:assemble Execution failed for task ':library_module:bundleDebugAar'. > Direct local .aar file dependencies are not supported when building an AAR. The resulting AAR would be broken because the classes and Android resources from any local .aar file dependencies would not be packaged in the resulting AAR. Previous versions of the Android Gradle Plugin produce broken AARs in this case too (despite not throwing this error). The following direct local .aar file dependencies of the :library_module project caused this error: ______.aar
I can see this was added to AGP a few months ago. But they provide no further info on why.
So.
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.
build.gradle
file withing the new directory:configurations.maybeCreate("default")
artifacts.add("default", file('[nameOfTheAar].aar'))
aar
into this new directoy. Next to the build.gradle
file.settings.gradle
file:include(":pathToTheCreatedDirectory")
aar
:implementation project(":pathToTheCreatedDirectory", configuration = "default")