Android Studio Project Structure
Description:
Android Studio Project Structure- in this article, I am showing you the android studio project structure in detail.
Android Studio Project structure
Android apps are made up of a whole set of artifacts called tree-like structures that can be displayed. The Android Studio tool window Project offers several views, Packages, and Android. Views work as a filter. Not every artifact (a file or directory) is in all views to see. The Android Studio Project view largely corresponds to the level representation of the file system. It visualizes the hierarchical structure of a project. Packages group files analogously to Java packages, where this makes sense. This view you may not use very often. Most convenient for development is probably the point of view android. as you see in the below Figure.
The Android view shows a simplified, partially flattened structure of a project. It allows quick access to important files and directories. Thematically related artifacts are also presented together if they are physically located in different directories. The tool window Project provides views either as tabs or as a drop-down list you can do this with the Show Views as Tabs command in the context menu of the window. To open it, right-click the window title mouse button on.
Let’s take a first look at important files and directories. To do this, activate the Android view. You will see two nodes, app, and Gradle scripts.
Unfold the latter. The build.gradle file occurs twice, the Files gradle.properties, settings.gradle and local.properties once each.
local.properties is automatically generated by Android Studio and should not be used by being edited by hand. It contains an entry pointing to the one used for the project Android SDK references. settings.gradle lists all modules of a project in android studio. The file will be updated as soon as a module is added or deleted. In what context modules are used, I will show you later. Many apps only need one module. With gradle.properties you can influence the build process. This is an advanced Task. Usually you do not need to edit this file.
The build.gradle file is duplicated. A version refers to the project in android studio. Each module has a further characteristic. there are build.gradle twice. Let’s take a look to throw the version for the app module. Double-clicking on build.gradle (modules: app) opens the file in a text editor.
You can see what this can look like in the below figure. Please do not make any changes at first. You can use the editor window at any time by clicking the cross on the tab or by Close by pressing the key combination (Ctrl)+(F4).
The android { … } block contains information you entered when creating the project in android studio. So application Id corresponds to the package name. minSdkVersion reflects your selection in the Minimum SDK drop-down list this attribute indicates which Android version must be present on a device as a minimum in order to use the being able to use the app. If this requirement is not met, the installation is canceled. In such a case, however, Google Play does not display the program at all. versionCode and versionName represent the version number of your app.As I’ll show you how to use these two variables later. compileSdkVersion and buildToolsVersion correspond to the version level of your Android SDK.
Now let’s take a look at the app module. It contains the branches manifests, java and res. Source texts are stored under java. You see that twice Package com.example.myapplication. This may irritate you if you have already worked with other development environments. Please think Remember that the Android view is an optimized (if you like, artificial) view of a project in android studio. A package contains the ApplicationTest class, which is another MainActivity. You have entered this name in the project assistant. You don’t have to worry about the test class at first. By the way, you can Conveniently create new classes by right-clicking on a package and selecting New Java Class.
The res branch consists of several sub-nodes. values ​​contain the file strings.xml. It includes texts that will later appear in the source text or in description files to be referenced for the user interface. For this purpose, the Android SDK tools generated a class called R. However, you must not edit these by hand. Therefore it is not available in the Android view.
the menu contains XML files for menus. I’ll show you how to use them somewhat later. The user interface of an app is defined in layout.
In drawable are graphics. Bitmaps can be in different resolutions be discarded. An example of a drawable is the app launcher icon, which has been stored here since the first Android version. Google now recommends it but to separate it from the rest of the graphics of the application. The project assistant has therefore been creating several directories mipmap-… for some time. New in Android 5 is a vector format that frees you, as a developer, from the thankless task of creating for to create many display variants graphics The manifests subnode contains the AndroidManifest.xml file. This is the central Description file of an application. In it, among other things, components of the program are listed. As you will see later, these are so-called activities, services, broadcast receivers, and content providers. The file also contains information about which rights an app needs and which hardware it expects.
already briefly mentioned other building blocks) from at least one activity. Here are, to put it very simply, screen pages. Various Aspects of an application such as lists, overviews, search, and input masks are implemented as separate activities and as sub-elements of <application> in AndroidManifest. xml entered.