如何生成jni库,不赘述,需要修改build.gradle加入如下语句即可:
不过注意此脚本适合:'com.android.tools.build:gradle:0.4版本,其后的版本可能默认加入JNI打包的步骤:
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->pkgTask.jniDir new File(buildDir, 'native-libs')
task copyNativeLibs(type: Copy) {
println 'call copyNativeLibs'
from fileTree(dir: 'libs', include: '**/*.so' )
into 'build/native-libs'
}
不过注意此脚本适合:'com.android.tools.build:gradle:0.4版本,其后的版本可能默认加入JNI打包的步骤:
tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->pkgTask.jniDir new File(buildDir, 'native-libs')
task copyNativeLibs(type: Copy) {
println 'call copyNativeLibs'
from fileTree(dir: 'libs', include: '**/*.so' )
into 'build/native-libs'
}