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的路径就不会出现这个错误.

相关文章:

  • 2021-10-15
  • 2021-07-20
  • 2022-12-23
  • 2021-12-29
  • 2021-06-26
  • 2021-12-09
  • 2022-12-23
  • 2022-01-18
猜你喜欢
  • 2021-04-04
  • 2021-04-09
  • 2021-05-10
  • 2022-12-23
  • 2021-04-24
  • 2022-12-23
相关资源
相似解决方案