记录下载as中打成jar包命令:
android {
....
}
task clearJar(type: Delete) {
delete 'build/outputs/yourjarname.jar'
}
task makeJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('build/outputs/')
include('classes.jar')
rename ('classes.jar', 'yourjarname.jar')
}
makeJar.dependsOn(clearJar, build)
//在终端执行生成JAR包
// gradlew makeJar
dependencies {
....
}
复制上面的task到Gradle中添加,编译即可在build/outputs/下生成对应的jar。