Error: Your project contains C++ files but it is not using a supported native build system

我在導入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 = []
    }
}

如下圖所示
這裏寫圖片描述
這樣就可以編譯成功了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章