AndroidStuido 导出jar
1:新建Modle,选择Android Libray,整理好相关代码,代码达到可以作为本地Library正常引用。
2: modle 的 build.gradle 增加如下任务
dependencies {
compile fileTree(dir: ‘libs’, include: [‘*.jar’])
testCompile ‘junit:junit:4.12’
compile ‘com.android.support:appcompat-v7:23.4.0’
}
//生成jar包task 根目录下:gradle makeJar 后生成build/libs/xx.jar
task clearJar(type: Delete) {
delete ‘build/libs/xx.jar’
}
task makeJar(type: Copy) {
from(‘build/intermediates/bundles/release/’)
into(‘build/libs/’)
include(‘classes.jar’)
rename(‘classes.jar’, ‘xx.jar’)
}
makeJar.dependsOn(clearJar, build)