https://www.jianshu.com/p/32cdfd323c56
//将ExoPlayer生成Jar包来使用
task deleteOldJar(type: Delete) {
//删除存在的
delete 'build/libs/ExoPlayer.jar'
}
task makeJar(type: org.gradle.api.tasks.bundling.Jar) {
//指定生成的jar名
baseName 'ExoPlayer'
def srcClassDir = [project.buildDir.absolutePath + "/intermediates/classes/release"];
from srcClassDir
//去掉不需要打包的目录和文件
exclude "**/BuildConfig.class"
exclude "**/BuildConfig\$*.class"
exclude "**/R.class"
exclude "**/R\$*.class"
//只导入资源路径集下的部分资源
include "com/google/android/exoplayer2/**/*.class"
}
makeJar.dependsOn(deleteOldJar, build)
//jar包默认生成在build/libs下
注意是在Module中的gradle中