Tek Eye Logo

Tek Eye

Android Project Structure

New to Android app development? After you have installed Android Studio, Google's preferred Integrated Development Environment (IDE), and run you first App, get familiar with the structure of an Android project. This article provides a very brief overview of the directories and files created.

Mike Bugdroid the Android Logo

With Android Studio running and a project open use the Project explorer to browse through all the folders and files. (In Studio's default configuration open the Project explorer by clicking on the Project tab on the left hand side.) The Project explorer supports different views, via the drop down list on the tab. With Project Files selected in Project explorer you get an everything view. Notice how it reflects the structure of the project as stored in the file system:

Android App Project Structure

The image above has the Project explorer view set to Project Files in the tab drop down to see a complete reflection of the project structure.

If a file is added to the directories outside of studio it will appear in the project structure in studio. Likewise deleting a file from the project in Studio will delete it from the file system (note it will not appear in the Recycle Bin in Windows).

Browse around the project to see where various files reside. In sub-folders there are source code files and resource files (e.g. layouts and images). There are folders and files for the build system (Gradle), and there are IDE configuration and settings files (Android Studio is based upon the IntelliJ IDE).

The First Level Folder

In the project structure the highest level folder is named after the project, as in the HelloWorld example above. In this first level project folder there are several (four) default folders and some configuration files for Gradle (the build tool), Git (a source control tool) and the IDE (IntelliJ based).

Only one of the first level folders is used in day-to-day development. The first level folders are:

  • .gradle - A Gradle cache and information directory (stores the version of Gradle being used for the project).
  • .idea - stores the Android Studio (IntelliJ) settings for the project.
  • app - The important folder, where our app code resides.
  • gradle - The Gradle build wrapper for the project.

The Important Source Code Folder

All the main Android related files and folders for the project live in (by default) the app folder. Under the app folder are a few (three) more Gradle and Git configuration files. There are three second level folders:

  • build - Build outputs.
  • libs - For additional libraries.
  • src - The important source code folder.

The src folder contains three folders:

  • androidTest - For application unit tests.
  • main - For app code and resources.
  • test - Class unit tests.

The main folder in src is where all the elements that make up an app go. Here is where the source code, screen designs, images and other media, strings and definitions are stored and organised. The names of the folders the various files are stored in are important because the folder structure is used to reference the files.

In the main folder is the vital AndroidManifest.xml file. This is used to configure the app and gives the final constructed App important properties. These properties appear in the compiled Android Application Package (APK) and are used by app stores, e.g. Google Play, and the Android Operating System (OS) to understand the requirements and abilites of the app. The default folders under main (for a Java based app) are:

  • java - Contains the source code in folders named after the packages to which the Java classes belong.
  • res - Contains all the various types of resources used by an app.

The app folder can be renamed (refactored) if required. As some of the SDK samples have done.

The Day-to-Day View

To simplify the view for day-to-day development select the Android setting in the the Project dropdown. This allows you to concentrate on the code and resources for the app. The Android view by default only shows the java and res folders (for a Java project), manifest files and build scripts for the app.

Android Project App Only View

Similarly use the Tests view to concentrate on test code, if you are writing automated tests for your app.

Android App Source Code Files

The code for an Android Java app is stored in Java class files. The Java classes are grouped into packages. Each class is stored in a .java file in a folder named after the package. The package name usually contains a reversed URL as a namespace, commonly based on an organisations web address or a persons personal web page or blog. The same namespace is used to uniquely identify an app to the app stores and Android OS. For example an Hello World app from Tek Eye may use uk.tekeye.helloworld as the namespace.

Studio Android View

The res folder stores all the separate resources for an app, this includes:

  • drawable - Images and screen elements (different screen sizes can be supported, e.g. drawable-hdpi).
  • layout - Store screen and fagment definitions (for portrait or landscape specific layouts create layout-port or layout-land folders).
  • mipmap - Launcher icons to support different screen densities.
  • values - Strings and constants (e.g. colors) definitions.

Other types of resources will be shown when added to an app, see the Android Developers App resources overview page for full details.

The Commonly Used Strings Resource

One of the most commonly used resource files are those that store string values. Almost all strings in an app are stored as a string resource in XML resource files. The initial default string's file is called strings.xml in the values folder. Unlike some resources, e.g. layouts, the file name is not important for strings. There can be many XML files storing string values. This helps with organising large projects, e.g. screen_1_strs.xml, screen_2_strs.xml, etc. See the Resource types overview pages on Android Developers for further detail on naming resources.

Gradle, the App Project Builder

Gradle is the default builder for Android projects. The Gradle related script files in the project directories are:

  • build.gradle - A build file for each Module and the overall project
  • settings.gradle - Project settings
  • gradle.properties - Project properties
  • local.properties - Automatically generated local configuration settings
  • proguard-rules.pro - ProGuard rules for the app (edit if using the WebView with JavaScript)
  • gradlew and gradlew.bat - Unix and Windows scripts for starting Gradle (ensuring the correct version of Gradle used by the project is available)

Miscellaneous Files

  • .gitignore - Folders and files that Git repositories should not store

All of the above is for a basic app and the default Studio installation. As with most modern IDEs a lot of settings can be modified and the structure can be changed to fit in with an organisation's requirements. However, sticking to the default settings usually produces less problems in the long run, especially as Android Studio tends to change settings as new versions are released.

See Also

This article is intended to provide a brief guide to the Android project structure in Android Studio. There is a lot more information available on the Android Developers Studio web pages and IntelliJ Help. Don't forget to try out the example apps that come with the Android Software Development Kit (SDK) to see how their files are organised. Enjoy your Android coding.

Author:  Published:  Updated:  

ShareSubmit to TwitterSubmit to FacebookSubmit to LinkedInSubmit to redditPrint Page

Do you have a question or comment about this article?

(Alternatively, use the email address at the bottom of the web page.)

 This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

markdown CMS Small Logo Icon ↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.


Articles on:

Android Programming and Android Practice Projects, HTML, VPS, Computing, IT, Computer History, ↓markdown↓ CMS, C# Programming, Using Windows for Programming


Free Android Projects and Samples:

Android Examples, Android List Examples, Android UI Examples



Tek Eye Published Projects