简体   繁体   English

在Android Studio中,为什么build.gradle的标签会显示“app”

[英]In Android Studio, why does the tab for build.gradle say 'app'

I'm an Android Studio noob. 我是Android Studio noob。 In 2.1.1, when I click on a file to edit, the file opens up in the edit pane and its tab usually reflects the name of the file. 在2.1.1中,当我单击要编辑的文件时,该文件在编辑窗格中打开,其选项卡通常反映文件的名称。 For instance, if I click on MyActivity.java, when it opens in the editor the tab for it says "MyActivity.java". 例如,如果我单击MyActivity.java,当它在编辑器中打开时,它的选项卡显示为“MyActivity.java”。 This is useful because I often have many files open at the same time and I can quickly scan across them and see what they are. 这很有用,因为我经常同时打开许多文件,我可以快速扫描它们并查看它们是什么。

But if I'm editing build.gradle the tab just says "app". 但如果我正在编辑build.gradle,则选项卡只会显示“app”。 Why? 为什么?

Edit: if I open other gradle files, eg, settings.gradle, the tab says "settings.gradle". 编辑:如果我打开其他gradle文件,例如settings.gradle,则选项卡显示“settings.gradle”。 XML files also seem to use their correct file name. XML文件似乎也使用正确的文件名。 So build.gradle seems to be special-cased. 所以build.gradle似乎是特殊的。 Why? 为什么?

I'll abstract some details here, so I definitely recommend that you take a Gradle for Android course if you can. 我将在这里抽象一些细节,所以如果可以,我绝对建议您选择Gradle for Android课程。 Udacity has one. Udacity有一个。

Essentially, Gradle creates a build.gradle file for the root folder of your project, for example, GooglePlayApp/. 从本质上讲,Gradle会为项目的根文件夹创建build.gradle文件,例如GooglePlayApp /。 Then it creates a build.gradle file for every part of your project. 然后,它为项目的每个部分创建一个build.gradle文件。 By part, I mean the app itself, which is located in the app/ folder, any external Java libraries, located in their own folder(s), any external Android libraries, also located in their own folder(s), and so on. 部分地,我的意思是应用程序本身,位于app /文件夹中,任何外部Java库,位于他们自己的文件夹中,任何外部Android库,也位于他们自己的文件夹中,依此类推。

Every one of these would have a build.gradle file. 其中每个都有一个build.gradle文件。 Gradle calls these parts, modules, in fact that's why under the Android view in the left pane in Android studio you see: Gradle调用这些部分,模块,实际上这就是为什么在Android工作室左侧窗格的Android视图下你会看到:

Build.gradle (module: project) // overall project build.gradle file
Build.gradle (module: app) // build.gradle file for your app
Build.gradle (module: myjavalibrary) // build.gradle file for a random java library
Build.gradle (module: myandroidlibrary) //build.gradle file for a random Android library

So to answer your question, Android Studio makes it easy for you to differentiate between these files by giving you the module name as opposed to the file name because the file name would be build.gradle for all of them. 因此,为了回答您的问题,Android Studio通过为您提供模块名称而不是文件名来轻松区分这些文件,因为文件名将是build.gradle。 Let me know if I need to elaborate further in the comments. 如果我需要在评论中进一步阐述,请告诉我。

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

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