android 项目打包jar
2019-03-26 本文已影响0人
To_HG
android项目打包成aar很简单,在app的build.gradle中改变apply的类型,然后build就可以打包aar
apply plugin: 'com.android.library'
打包成jar,同样需要上步操作,但是还需要在app的build.gradle中android{}标签下增加一些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)
然后就可以看见在右侧gradle中 <编译module>/Tasks/other/这两个选项了,
先点击delBuild删除当前jar,然后makejar生成jar,
屏幕快照 2019-03-26 下午5.01.59.png
然后就可以引用了。