我在導入android studio 代碼的時候運行報錯:
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:
https://developer.android.com/studio/build/experimental-plugin.html.
這個情況是項目中使用了NDK—jni導致的配置錯誤,看了別人的解決方法,我的問題也解決了:
首先在工程目錄下的gradle.properties文件的末尾加上一句:Android.useDeprecatedNdk=true
如圖:
然後再在文件build.gradle(Module:app)裏面的buildTypes類中添加一個這樣的方法
sourceSets {
main {
jni.srcDirs = []
}
}
如下圖所示
這樣就可以編譯成功了