如何解決Your project contains C++ files but it is not using a supported native build system


最近因為項目需要下載Android終端模擬器(Android-Terminal-Emulator)源碼進行調試編譯,編譯過程中出現報錯

Error:Execution failed for task ':libtermexec:compileReleaseNdk'.
> 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.

頓時不知道所以然,Google以后,在stackoverflow找到解決方法,
一、在項目的gradle.properties添加
android.useDeprecatedNdk=true

二、在module的build.gradle(Module:app)的buildTypes上面添加sourceSets屬性

sourceSets {
main {
jni.srcDirs = []
  }
}

buildTypes{
}

最后運行gradle腳本更新build,在編譯module即可。

這個問題主要是因為Android studio以前使用ndkCompile后來廢棄掉了,Android-Terminal-Emulator沒有最近沒有更新的緣故。具體的編譯最新的NDK編譯方式可以看官網
https://developer.android.com/studio/projects/add-native-code.html

參考鏈接:http://stackoverflow.com/questions/40065871/error-your-project-contains-c-files-but-it-is-not-using-a-supported-native-bu/40283476
https://developer.android.com/studio/projects/add-native-code.html

同行的網友也寫過解決方案
http://blog.csdn.net/susubuhui/article/details/53057188
http://www.cnblogs.com/qianyukun/p/6405291.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM