Android Studio: This file not part of the project, but the project builds successfully

前端 未结 5 493
后悔当初
后悔当初 2021-01-13 20:03

I have a strange problem that suddenly appeared in android studio. I created a new cpp file, and included it in Android.mk. Then I synced the project. However, android studi

5条回答
  •  耶瑟儿~
    2021-01-13 20:36

    I had a similar problem. Like yourself, I have tried everything.

    • Invalidate and Restart: Doesn't work
    • Manual deleting folders: .gradle .idea .ndkbuild etc. doesn't work
    • Clean, Rebuild, Link C++ Files: Doesn't work

    One thing that kind of helped me was: I changed the NDK version. I compiled, then got a compilation error (didn't matter because it was the wrong version of NDK anyway), then I reverted to the original NDK. This appeared to solve the problem, however, it got back again.

    My solution was to reset Android Studio to factory settings. If you are on Linux, you can start by deleting these folders:

    rm -rf ~/.android
    
    rm -rf ~/.AndroidStudio3.4
    

    Then you download and run your Android Studio and not import anything from anywhere.

    I suspect the problem was caused by one of the plugins I've installed.

    It may be a good idea to backup those two folders from time to time and reload them from there if necessary.

    EDIT: It seems that my problem persisted after the above solution after adding more .cpp files. After seeing that, I searched where that popup came from. It follows that "This file is not part of project..." popup is pushed from ndk-build. (Class name: NewCppSourceNotificationProvider - StaleCppProjectNotificationPanel). What I tried, and what worked so far; I used Android Studio 3.5 Canary13 with NDK version r19c (Stable version). I hope this helps you.

提交回复
热议问题