Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Android_Project Structure

Miroslav Smukov edited this page May 13, 2016 · 9 revisions

Project Structure

Let's go over the Android project structure, we'll start with how the Android Studio is setting up the project structure to give us a clean overview of the important files within our projects.

Android Project View

As already mentioned, Android Studio will set the Android Project View as the default view when you initially create a project. This view shows a flattened version of your project's structure that provides quick access to the key source files of Android projects and helps you work with the new Gradle-based build system. The Android project view:

  • Groups the build files for all modules at the top level of the project hierarchy.
  • Shows the most important source directories at the top level of the module hierarchy.
  • Groups all the manifest files for each module.
  • Shows resource files from all Gradle source sets.
  • Groups resource files for different locales, orientations, and screen types in a single group per resource type.

Enabling the Android Project View

If the Android Project View is not enabled by default in your Android Studio, you can enable it by clicking Project and selecting Android, as shown in the image below.

Android Project View

Using the Android Project View

The Android project view shows all the build files at the top level of the project hierarchy under Gradle Scripts. Each project module appears as a folder at the top level of the project hierarchy and contains these three elements at the top level:

  • java/ - Source files for the module.
  • manifests/ - Manifest files for the module.
  • res/ - Resource files for the module.

Below you can see the difference in normal Project View (left), and the Android Project View (right). Note that Android Project View doesn't represent the structure of the project on disk itself.

Android Project View

App Components

App components are the essential building blocks of an Android app. Each component is a different point through which the system can enter your app. Not all components are actual entry points for the user and some depend on each other, but each one exists as its own entity and plays a specific role—each one is a unique building block that helps define your app's overall behavior.

There are four different types of app components. Each type serves a distinct purpose and has a distinct lifecycle that defines how the component is created and destroyed.

Here are the four types of app components:

  • Activities - An activity represents a single screen with a user interface. The activities work together to form a cohesive user experience in an app, however each one is independent of the others. As such, a different app can start any one of these activities, if your app allows it.
  • Services - A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface.
  • Content Providers - A content provider manages a shared set of app data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your app can access. Through the content provider, other apps can query or even modify the data, if the content provider allows it. Content providers are also useful for reading and writing data that is private to your app and not shared.
  • Broadcast Receivers - A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system — for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Apps can also initiate broadcasts. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs.

A unique aspect of the Android system design is that any app can start another app’s component.

Android Manifest

http://developer.android.com/guide/components/fundamentals.html#Manifest

Resources

http://developer.android.com/guide/components/fundamentals.html#Resources

Gradle Scripts

http://developer.android.com/tools/building/configuring-gradle.html

References

Clone this wiki locally