实现(fileTree(mapOf(“dir”到“libs”,“include”到listOf(“*.jar”))))
实施(文件(“BudgetLibraryNBB.aar”))
实现(fileTree(mapOf(“dir”到“libs”,“include”到listOf(“*.jar”))))
实施(文件(“BudgetLibraryNBB.aar”))
推荐的方法是使用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:
这真的很简单,只需包含*.aar
在fileTree
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
PS。当然,如果您仍然将库保存在libs
目录中