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

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.

主站蜘蛛池模板: 新郑市| 凌源市| 平遥县| 新建县| 汝城县| 宜兰市| 贺州市| 方山县| 南陵县| 长汀县| 忻州市| 河池市| 海城市| 博野县| 兴宁市| 肥西县| 浑源县| 宜城市| 昌黎县| 祁门县| 陆川县| 三明市| 资溪县| 邵阳县| 榆林市| 桐庐县| 赤峰市| 南和县| 晋中市| 竹山县| 津南区| 鸡泽县| 东山县| 耒阳市| 龙陵县| 白朗县| 新兴县| 喀什市| 东源县| 汨罗市| 岢岚县|