官术网_书友最值得收藏!

The Android project structure

The root directory of your Android project contains various files and subdirectories. Or, should I say, the root folder of your Android project contains various files and subfolders. Ha ha. We'll use the words "folder" and "directory" interchangeably throughout this book, just as Android Studio also seems to do (actually, there is a difference, as discussed at http://stackoverflow.com/questions/29454427/new-directory-vs-new-folder-in-android-studio).

As shown in the Android hierarchy, in the following sample Cardboard project, the root directory contains an app/ subdirectory, which, in turn, contains the following subdirectories:

  • app/manifests/: This contains the AndroidManifest.xml manifest file that specifies the components of the application, including activities (UI), device permissions, and other configurations
  • app/java/: This contains subfolders with your application Java files that implement the application's MainActivity and other classes
  • app/res/: This contains subfolders with resources, including the layout XML definition files, values definitions (strings.xml, styles.xml, and so on), icons, and other resource files
    The Android project structure

It's not a coincidence that these directories correspond to the boxes in the topmost row of the preceding Gradle build process diagram; they supply the source files that are run through the Java compiler.

Also, there are Gradle scripts under the root directory, which do not need to be edited directly since the Android Studio IDE provides convenient dialog boxes to manage the settings. In some cases, you might find it to be easier to modify these files directly.

Notice that in the upper-left corner of the hierarchy pane is a tab select menu. In the preceding screenshot, it is set to Android, which just shows the Android-specific files. There are other views that might also be useful, such as Project, which lists all the files and subdirectories under your project root directory, as shown in the following screenshot, for the same app. The Project hierarchy shows the files as they are structured on the actual filesystem. The other hierarchies artificially restructure your project to make it easier to work with.

The Android project structure

Tip

From time to time, you'll need to switch between the Android view and Project view.

主站蜘蛛池模板: 咸丰县| 郁南县| 灵石县| 林口县| 灵丘县| 清涧县| 商南县| 翁源县| 响水县| 张北县| 十堰市| 浮梁县| 万盛区| 互助| 泰州市| 屏山县| 天水市| 中牟县| 无极县| 钟祥市| 岐山县| 阳城县| 邢台市| 横山县| 台江县| 思南县| 思茅市| 嘉荫县| 永和县| 乌拉特中旗| 平原县| 博客| 莎车县| 萨嘎县| 陆川县| 长汀县| 延庆县| 偏关县| 自治县| 武平县| 米泉市|