Android Studio 将libs下的JAR打合并打成一个总jar包

task buildJar(type: Jar, dependsOn: ['compileReleaseJavaWithJavac']) { //  task buildJar(type: Jar, dependsOn: ['build'])
    //导出的jar文件的名称
    archiveName = "test-debug.jar"
    //需打包的资源所在的路径集
    from('build/intermediates/classes/release')
    from fileTree(dir: 'src/main')
    from (project.zipTree('libs/extlib_out.jar')) //第三方jar包
    destinationDir = file('../libs')  // //导出的jar文件的存放目录(未指定则默认存放在build/libs下)  destinationDir = file('D:/libs')
    exclude('**/R.class')
    exclude('**/R\$*.class') //过虑资源文件
    exclude "com/r/c/v/BuildConfig.class"
    exclude "com/r/c/v/BuildConfig\$*.class" //过滤BuildConfig
    //include "**/*.*"    //需要打包的类 如 // include('com/reginer/mytest/*.class')
    include('com/r/c/v/*.class')
    include "assets/**"   //引入assets目录下的资源
    include "com/android/aop/**"  //第三方jar包的包路径
}
然后点击下面选择的buildJar,可以直接编译,后会在该module的上一层目录的libs目录下生成一个
test-debug.jar的jar包


没有更多推荐了,返回首页