1炫加、首先在Android Library項(xiàng)目的gradle腳本只需要在開(kāi)頭聲明 ??apply plugin: 'com.android.library'
2、執(zhí)行./gradlew assembleRelease,就可以在LIbrary 項(xiàng)目中 build/outputs/aar 文件夾里生成aar文件
3恃鞋、把a(bǔ)ar文件放在一個(gè)文件目錄內(nèi)洞慎,比如就放在libs目錄內(nèi)
4爪幻、在app的build.gradle文件添加如下內(nèi)容
? ? ? ? ? ? ? ? ? ? ? ? ? ??repositories {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? flatDir {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?dirs 'libs' //this way we can find the .aar file in libs folder
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ? }
5菱皆、之后在其他項(xiàng)目中添加一句gradle依賴(lài)便方便的引用了該library
dependencies {
compile(name:'test', ext:'aar')
}