Android Studio Linking an external C++ project 时候 报Invalid file name. Expected: CMakeLists.txt

 

Android Studio 右键Linking an external C++ project 时候

报Invalid file name. Expected: CMakeLists.txt错误

 

查看Android Studio 源码:

 @Nullable
  private String validateProjectFilePath(@NotNull File file) {
    if (!file.exists()) {
      return "The selected file does not exist";
    }
    if (myBuildSystemCombo.getSelectedItem() == BuildSystem.CMAKE && !file.getName().equals("CMakeLists.txt")) {
      return "Invalid file name. Expected: CMakeLists.txt";
    }
    else if (myBuildSystemCombo.getSelectedItem() == BuildSystem.NDK_BUILD && !FileUtilRt.extensionEquals(file.getPath(), "mk")) {
      return "Invalid file extension. Expected: .mk";
    }
    return null;
  }

 

发现是选择条目必须是BuildSystem.CMAKE,也就是必须选择路径,如果直接复制粘贴的路径,就会提示错误。

解决方案:

 

一步步选择CmakeLists.txt路径即可,不要直接粘贴CmakeLists.txt的路径就不会出现这个错误.

posted @ 2016-10-28 11:53  狂奔的小狮子  阅读(955)  评论(0编辑  收藏  举报