Android Studio:此文件不属于项目,但项目构建成功 [英] Android Studio: This file not part of the project, but the project builds successfully

查看:50
本文介绍了Android Studio:此文件不属于项目,但项目构建成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在android studio中突然出现了一个奇怪的问题.我创建了一个新的 cpp 文件,并将其包含在 Android.mk 中.然后我同步了项目.但是,android studio 仍然抱怨该文件不是项目的一部分,我需要同步,但整个项目构建成功.

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 studio still complains that the file is not part of the project and that I need to sync, BUT the whole project builds successfully.

同样,如果我从 Android.mk 中删除它没有抱怨的其他旧文件之一,然后重新同步,然后尝试构建项目,如预期的那样构建失败,但 android studio 不会抱怨该文件不再是项目的一部分.

Likewise, if I remove one of the other older files from Android.mk that it did not complain about, and resyncs and then tries to build the project, as expected the build fails, but android studio does NOT complain that that file is not part of the project anymore.

不知何故,突然间 android studio 编辑器无法正确识别哪些文件已同步并且是项目的一部分,但在编译期间一切都按预期工作.

So somehow, suddenly the android studio editor is not able to correctly identify which files have been synced and are part of the project, but during compilation everything works as expected.

有谁知道如何解决这个烦人的问题?我尝试过干净的项目,使缓存无效/重启以及更新 android studio 没有运气(AS 3.4 版).

Does anyone know how to fix this annoying problem? I have tried clean project, invalidate caches/restart as well as updating android studio without luck (AS version 3.4).

推荐答案

我遇到了类似的问题.和你一样,我什么都试过了.

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

  • 无效并重新启动:不起作用
  • 手动删除文件夹:.gradle .idea .ndkbuild 等不起作用
  • 清理、重建、链接 C++ 文件:不起作用

对我有帮助的一件事是:我更改了 NDK 版本.我编译,然后出现编译错误(没关系,因为无论如何它都是错误的 NDK 版本),然后我恢复到原始 NDK.这似乎解决了问题,但是,它又回来了.

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.

我的解决方案是将 Android Studio 重置为出厂设置.如果您使用的是 Linux,您可以先删除这些文件夹:

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

然后你下载并运行你的 Android Studio,而不是从任何地方导入任何东西.

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.

在添加更多 .cpp 文件后,我的问题似乎在上述解决方案后仍然存在.看到那个之后,我搜索了那个弹出窗口的来源.随之而来的是此文件不是项目的一部分..."弹出窗口是从 ndk-build 推送的.(类名:NewCppSourceNotificationProvider - StaleCppProjectNotificationPanel).我尝试过的方法以及到目前为止有效的方法;我使用了带有 NDK 版本 r19c(稳定版)的 Android Studio 3.5 Canary13.我希望这对您有所帮助.

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.

这篇关于Android Studio:此文件不属于项目,但项目构建成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆