方法一: 将libs文件夹下的so文件,通过gradle配置任务编译成jar文件。 - apply plugin: 'com.android.library'
-
- android {
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
- defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- }
-
-
- /** 导入so文件 */
- task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") {
- destinationDir file("$projectDir/libs")
- baseName "Native_Libs2"
- extension "jar"
- from fileTree(dir: "libs", include: "**/*.so")
- into "lib"
- }
-
- tasks.withType(JavaCompile) {
- compileTask -> compileTask.dependsOn(nativeLibsToJar)
- }
-
-
- }
-
- dependencies {
- provided fileTree(dir: 'libs', include: ['*.jar'])
- }
复制代码
方法二: 通过插件将so文件依赖到jniLibs文件夹。 方法三: 最佳方法。 - android {
- sourceSets.main.jniLibs.srcDirs = ['libs']
-
- compileSdkVersion rootProject.ext.compileSdkVersion
- buildToolsVersion rootProject.ext.buildToolsVersion
-
- defaultConfig {
- minSdkVersion rootProject.ext.minSdkVersion
- targetSdkVersion rootProject.ext.targetSdkVersion
- }
复制代码 当然,开发完APP也是需要进行全方位的检测:www.ineice.com
|