android官方说明
https://developer.android.google.cn/studio/projects/android-library.html
1.android app module依赖 aar module
默认是不支持productFlavors 的,如果需要支持,则需添加两个配置
1)默认情况下,应用模块会使用库的发布构建,即使在使用应用模块的调试构建类型时亦是如此。要使用库中不同的构建类型,您必须将依赖项添加到应用的 build.gradle
文件的 dependencies
块中,并在库的 build.gradle
文件中将 publishNonDefault
设置为 true
。例如,您应用的 build.gradle
文件中的以下代码段会使应用在应用模块于调试模式下构建时使用库的调试构建类型,以及在应用模块于发布模式下构建时使用库的发布构建类型:
dependencies {
debugCompile project(path: ':library', configuration: 'debug')
releaseCompile project(path: ':library', configuration: 'release')
}
{
debugCompile project(path: ':library', configuration: 'debug')
releaseCompile project(path: ':library', configuration: 'release')
}
2)您还必须在自己库的 build.gradle
文件的 android
块内添加以下代码行,以便将此库的非发布配置展示给使用它的项目:
android {
...
publishNonDefault true
}
{
...
publishNonDefault true
}
不过请注意,设置 publishNonDefault
会增加构建时间。
2.aar的资源文件名要加上个前缀,以防止与宿主app的资源文件id冲突
3.有so包的依赖,也要在宿主app的gradle文件中添加