在Android Studio2.2.3中开发时,因为引用了第三方.so库,在Project --> app --> src --> main 下新建了jniLibs文件夹,并将.so复制在下面,编译时出错如下:
Error:Execution failed for task ':app:compileDebugNdk'.
> Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
解决方法:
在Project --> app --> build.gradle文件中android {}中添加如下代码后,同步Gradle文件即可。
android {
......
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = []
}
}