实现(fileTree(mapOf(“ dir”到“ libs”,“ include”到listOf(“ *。jar”))))
实现(文件(“ BudgetLibraryNBB.aar”))
答案 0 :(得分:1)
recommond方法是使用File
-> New
-> New Module
-> Import .JAR/.AAR Package
导入它,然后在库模块build.gradle.kts
文件中引用它:
implementation(project(":BudgetLibraryNBB"))
如果将其放入libs目录:
implementation(files("./libs/BudgetLibraryNBB.aar"))
或
implementation(files("$projectDir/libs/BudgetLibraryNBB.aar"))
在执行bundleAar任务时,您将遇到以下错误:
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:
答案 1 :(得分:0)
这真的很简单,只需在*.aar
中包含fileTree
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
PS。当然,如果您仍将图书馆保留在libs
目录中