android項(xiàng)目打包成aar很簡(jiǎn)單,在app的build.gradle中改變apply的類型准验,然后build就可以打包aar
apply plugin: 'com.android.library'
打包成jar赎线,同樣需要上步操作,但是還需要在app的build.gradle中android{}標(biāo)簽下增加一些task
def SDK_DES = "build/outputs/jar/"
def JAR_FILE = "build/intermediates/bundles/release/classes.jar"
def JAR_NAME = "name"
task delBuild(type: Delete) {
delete JAR_NAME+ ".jar"
}
task makeJar(type: Jar) {
from zipTree(JAR_FILE)
baseName = JAR_NAME
destinationDir = file(SDK_DES)
}
makeJar.dependsOn(delBuild, build)
然后就可以看見(jiàn)在右側(cè)gradle中 <編譯module>/Tasks/other/這兩個(gè)選項(xiàng)了,
先點(diǎn)擊delBuild刪除當(dāng)前jar,然后makejar生成jar糊饱,
然后就可以引用了垂寥。