方法一:
将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']) }
参考资料:http://blog.csdn.net/wulianghuan/article/details/44567001
方法二:
通过插件将so文件依赖到jniLibs文件夹。
参考资料:http://www.jcodecraeer.com/a/anzhuokaifa/Android_Studio/2015/0804/3256.html
插件/开源项目 :https://github.com/nhachicha/android-native-dependencies
方法三:
最佳方法。
android { sourceSets.main.jniLibs.srcDirs = ['libs'] compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion defaultConfig { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。