2019独角兽企业重金招聘Python工程师标准>>>
第一种方式
1.创建一个工程,选择AndroidApplication
2.创建一个module选择Android Library
3.修改Library module的build.gradle文件,添加一下任务
//task to delete the old jar task deleteOldJar(type: Delete) { delete 'release/dynamicload.jar' } //task to export contents as jar task exportJar(type: Copy) { from('build/intermediates/bundles/release/') into('release/') include('classes.jar') ///Rename the jar rename('classes.jar', 'dynamicload.jar') } exportJar.dependsOn(deleteOldJar, build)
4.打开Gradle面板,选择Tasks->Other->exportJar,并执行。
如果执行成功,会得到dynamicload.jar
第二种方式
1.创建一个工程,选择AndroidApplication
3.修改Library module的build.gradle文件,
把
apply plugin: 'com.android.application'
修改为
apply plugin: 'com.android.library'
defaultConfig修改为
defaultConfig { minSdkVersion 24 targetSdkVersion 25 }
添加一下任务
//task to delete the old jar task deleteOldJar(type: Delete) { delete 'release/dynamicload.jar' } //task to export contents as jar task exportJar(type: Copy) { from('build/intermediates/bundles/release/') into('release/') include('classes.jar') ///Rename the jar rename('classes.jar', 'dynamicload.jar') } exportJar.dependsOn(deleteOldJar, build)
4.打开Gradle面板,选择Tasks->Other->exportJar,并执行。
如果执行成功,会得到dynamicload.jar
另一段脚本
引入assets和meta-inf文件
//打jar包
def SDK_BASENAME = "SkyDataReportImpl";
def sdkJarPath = "build";
def zipFile = file('build/intermediates/bundles/release/classes.jar')
task deleteOldJar(type: Delete) {
delete 'build/SkyDataReportImpl.jar'
}
task makeJar(type: Jar) {
from zipTree(zipFile)
from fileTree(dir: 'src/main', includes: ['assets/**','META-INF/versioninfo.properties'])
baseName = SDK_BASENAME
destinationDir = file(sdkJarPath)
}
makeJar.dependsOn(deleteOldJar,build)