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

查看:205
本文介绍了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).我尝试过的,到目前为止有效的;我将Android Studio 3.5 Canary13与NDK版本r19c(稳定版)一起使用.希望对您有帮助.

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天全站免登陆