简体   繁体   English

如何从 android studio 3.2 中删除 generatedJava

[英]how to remove generatedJava from android studio 3.2

Android studio 3.2安卓工作室 3.2

在此处输入图像描述

I have migrated my project to android studio 3.2.我已将我的项目迁移到 android studio 3.2。 After migration I see generatedJava folder in my Android folder structure.迁移后,我在我的 Android 文件夹结构中看到了generatedJava文件夹。 I don't have any use of it.我没有任何用处。

How can I remove this generatedJava folder from Android Studio ?如何从Android Studio中删除这个生成的Java 文件夹?

Why you want to remove this?为什么要删除它?

Here is some explanation behind the reason to keep it as it is.

No one forces you to look into this folder.没有人强迫您查看此文件夹。 But if your project has a lot of generated code (room, data binding, dagger) then it is very handy to have quick access to these files in order to check if they were generated properly, set some breakpoints for debugging etc...但是如果您的项目有很多生成的代码(房间、数据绑定、匕首),那么快速访问这些文件以检查它们是否正确生成、设置一些断点以进行调试等会非常方便...

I really do not see anything bad about this folder being visible.我真的没有看到这个文件夹可见的任何不好的地方。 In addition if its in the "generated" folder, then everyone could understand the contents are dynamic.此外,如果它在“生成”文件夹中,那么每个人都可以理解内容是动态的。

In addition it is good even for beginners to see that their code causes some generated code also.此外,即使对于初学者来说,看到他们的代码也会导致一些生成的代码也是一件好事。 They will understand faster that it is not black magic happening behind room, dagger, data binding etc by seeing what is the actual code generated for a short annotation.通过查看为简短注释生成的实际代码是什么,他们将更快地理解这不是房间、匕首、数据绑定等背后发生的黑魔法。

You can't actually remove it since it has been in your project also before:您实际上无法删除它,因为它之前也在您的项目中:

build/generated/source/r/<current flavor>/<current build type>/

But now, it reappear in the Android view mode of the project so that we can use for our purposes.但是现在,它重新出现在项目的 Android 视图模式中,以便我们可以将其用于我们的目的。 There has been many topics like this before and unfortunately I couldn't find anything related to remove or hiding this in the Android Studio.以前有很多这样的话题,不幸的是我在 Android Studio 中找不到与删除或隐藏相关的任何内容。

You also, if you remove it, it will reappear again since it is auto-generated by Android Studio so, perhaps this is gonna be a feature request for the next releases of Android Studio IDE itself.你也,如果你删除它,它会再次出现,因为它是由 Android Studio 自动生成的,所以,也许这将是 Android Studio IDE 本身的下一个版本的功能请求。

Also, as mentioned, it can be helpful but, since it is added in the Android view mode, looks weird and unfamiliar.此外,如前所述,它可能会有所帮助,但由于它是在 Android 视图模式下添加的,因此看起来很奇怪且不熟悉。 But there is no harm of seeing it in there.但是在那里看到它并没有什么坏处。

Sorry to disappoint you很抱歉让你失望了

右键单击生成,然后隐藏忽略的文件。

Build -> Clean Project.构建 -> 清理项目。 Generated files will be removed.生成的文件将被删除。

There are several schemes in which android studio displays project tree. android studio显示项目树有几种方案。 If you are really troubled with generated java directory, you may try other schemes. 如果您真的对生成的Java目录感到困惑,则可以尝试其他方案。

在此处输入图片说明

Many of the schemes for example Project Source Files does not show generatedJava directory. 许多方案(例如“项目源文件”)都不显示generateJava目录。

Hope this helps somewhat. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM