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

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.

主站蜘蛛池模板: 达拉特旗| 紫阳县| 凤翔县| 湖南省| 汉川市| 濉溪县| 厦门市| 高台县| 双牌县| 咸丰县| 尤溪县| 揭阳市| 泰和县| 视频| 灵宝市| 罗源县| 方城县| 镇平县| 平原县| 富宁县| 体育| 鄯善县| 桃园县| 中卫市| 普安县| 合川市| 昌吉市| 松潘县| 马边| 德格县| 佛教| 万年县| 云龙县| 玛沁县| 宿迁市| 西昌市| 伊宁市| 和林格尔县| 苏尼特左旗| 垫江县| 安化县|