This file is not part of the project Please include it in the appropiate build file(build.gradle,...

问题描述:

jni项目中,cpp文件翻红,文件上方黄条提示:This file is not part of the project Please include it in the appropiate build file(build.gradle, CMakeLists.txt…),但可以运行。

解决方法:

绝大多数原因是因为Cmake版本不匹配,首先在SDK Manager中切换CMake版本


SDK Manager

如果运行后仍然不行,则尝试强制指定版本:

app build.gradle
android {
externalNativeBuild {
        cmake {
            path file('CMakeLists.txt')
            version "3.6.4111459" #修改为你的版本
        }
    }
 }
local.properties
cmake.dir=C\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk\\cmake\\3.6.4111459 #修改为你的路径
sdk.dir=C\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk
ndk.dir=C\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk\\ndk\\21.0.6113669

你可能感兴趣的:(This file is not part of the project Please include it in the appropiate build file(build.gradle,...)