Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add .aar file to gradle.kts in android studio?

implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

implementation(files("BudgetLibraryNBB.aar"))

like image 887
Syed Danish Haider Avatar asked May 12 '20 10:05

Syed Danish Haider


1 Answers

The recommond method is import it using File -> New -> New Module -> Import .JAR/.AAR Package, then referencing it in the library module build.gradle.kts file:

implementation(project(":BudgetLibraryNBB"))

If you put it into libs dir:

implementation(files("./libs/BudgetLibraryNBB.aar"))

or

implementation(files("$projectDir/libs/BudgetLibraryNBB.aar"))

when you are executing bundleAar task, you will meet error below:

Execution failed for task ':common: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 :common project caused this error: 

like image 110
Victor Avatar answered Sep 28 '22 16:09

Victor