1. File ->new Moudle -> android library
这样就创建了一个library工程 打开他的build.gradle 工程
apply plugin: ‘com.android.library‘
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘
}
}
}
dependencies {
compile fileTree(dir: ‘libs‘, include: [‘*.jar‘])
testCompile ‘junit:junit:4.12‘
compile ‘com.android.support:appcompat-v7:23.4.0‘
}
//==============以下是要添加的内容======================
//task to delete the old jar 这个表示将会删除这个目录下的*.jar名称的旧版本
task deleteOldJar(type: Delete) {
delete ‘release/AndroidPlugin.jar‘
}
//task to export contents as jar 将from(*)该目录下的文件复制到release/下 并更改名称为Bsdiff.jar
task exportJar(type: Copy) {
from(‘build/intermediates/bundles/release/‘)
into(‘release/‘)
include(‘classes.jar‘)
///Rename the jar
rename(‘classes.jar‘, ‘Bsdiff.jar‘)
}
exportJar.dependsOn(deleteOldJar, build)
这样设置以后 将你想要打包的文件放到src/main/java目录下
点击上图exportJar 就可以在你创建的library/release/*.jar找到你打包完成的jar包 就可以了