build.gradle里面:
defaultConfig {
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
ndk {
abiFilters"armeabi-v7a","arm64-v8a"
}
}
增加task对编译完成的库进行copy
// task部分在右边的gradle窗口手动执行
task buildJar(type: Jar, dependsOn: ['build']) {
delete 'output'
//导出的jar文件名称
archiveName = 'encoder.jar'
//从哪个目录打包jar
from('build/intermediates/classes/debug')
exclude('**/R.class')
exclude('**/BuildConfig.class')
//需要打包的类
include('com/abc/video/encoder/*.class')
//导出的jar文件的存放目录(未指定则默认存放在build/libs下)
//destinationDir = file('output')
copy {
from 'build/libs/encoder.jar'
into 'output'
}
//copy so库
copy {
from 'build/intermediates/intermediate-jars/debug/jni'
into 'output/jni'
}
}
网友评论