第一步:在项目中的build.gradle文件中将
apply plugin: 'com.android.application'
改为
apply plugin: 'com.android.library'
同时将applicationId删除,这样Module就成了一个lib库
第二步:在lib中的build.gradle中添加生成jar包的task任务
方式一:
def SDK_BASENAME = "Sdk";//打包后名字
def SDK_VERSION = "_V1.0";//${defaultConfig.versionName}
def sdkDestinationPath = "build";//保存目录
def zipFile = file('build/intermediates/bundles/release/classes.jar')
task deleteBuild(type: Delete) {//删除jar包
delete sdkDestinationPath + "/" + SDK_BASENAME + SDK_VERSION + ".jar"
}
task makeJar(type: Jar) {//生成jar
from zipTree(zipFile)
from fileTree(dir: 'src/main', includes: ['assets/**'])
baseName = SDK_BASENAME + SDK_VERSION
apply plugin: 'com.android.application'
改为
apply plugin: 'com.android.library'
同时将applicationId删除,这样Module就成了一个lib库
第二步:在lib中的build.gradle中添加生成jar包的task任务
方式一:
def SDK_BASENAME = "Sdk";//打包后名字
def SDK_VERSION = "_V1.0";//${defaultConfig.versionName}
def sdkDestinationPath = "build";//保存目录
def zipFile = file('build/intermediates/bundles/release/classes.jar')
task deleteBuild(type: Delete) {//删除jar包
delete sdkDestinationPath + "/" + SDK_BASENAME + SDK_VERSION + ".jar"
}
task makeJar(type: Jar) {//生成jar
from zipTree(zipFile)
from fileTree(dir: 'src/main', includes: ['assets/**'])
baseName = SDK_BASENAME + SDK_VERSION