Accepted answer

the mystery: android studio's project structure and build system

i don't know if this is because of the gradle build system (i'd wager it is), but i'll tell you what i've understood so far.

update 4: 2014/09/11 added cheat sheet for buildtypes, flavors and variants(i finally feel confident to write this :d)
update 3: 2014/09/11 updated the comparison workspaces and projects to be precise
update 2: 2014/04/17 added more detail to as project structure
update 1: 2013/07/29 added intellij project structure

the intellij's project structure (shown at the end) is for intellij with the android plugin. the android studio, however, has a project structure divided like so:

structure: projects and modules

module in android studio is like a project in eclipse

project in android studio is like a workspace in eclipse (to be precise, a workspace with interdependent projects)

from the documentation (android studio is based on intellij idea) :

whatever you do in intellij idea, you do that in the context of a project. a project is an organizational unit that represents a complete software solution.

your finished product may be decomposed into a series of discrete, isolated modules, but it's a project definition that brings them together and ties them into a greater whole.

for android, it means one project per app, and one module per library and per test app.

there are multiple issues if you try to build multiple apps within the same project. it's possible, but if you try (like i did), you will see that almost everything is designed to work with a single app per project.

for example, there is an option to "rebuild the project", which makes no sense with multiple apps, many other project settings would be useless, and the built-in vcs system isn't great when you have multiple repositories.

structure: folder structure

android studio project structure

top level folders

1. main project

this would be entire project context (eclipse land: like your workspace but limited to what's relevant to your project). ex: helloworldproject if the name of the application you gave was helloworld

2. .idea

this where project specific metadata is stored by android studio (as). (eclipse land: file)

3. project module

this is the actual project. ex: helloworld if your application name you gave was helloworld

4. gradle

this is where the gradle build system's jar wrapper i.e. this jar is how as communicates with gradle installed in windows (the os in my case).

5. external libraries

this is not actually a folder but a place where referenced libraries (eclipse land: referenced libraries) are shown. here's where the targeted platform is shown etc.

[side note: this where many of us in eclipse land used to delete the referenced libraries and fix project properties to fix reference errors, remember?]

project folder in detail

this is number #3 in the above list. has the following sub dirs

1. build

this has all the complete output of the make process i.e. classes.dex, compiled classes and resources, etc.

in the android studio gui, only a few folders are shown. the important part is that your is found here under build/source/<flavor>/r/<build type(optional)>/<package>/

2. libs

this is the standard libs folder that you see in eclipse land too

3. src

here, you only see the java and res folder which correspond to the src folder and res folder in eclipse land. this is much welcomed simplification imho.

note on modules:

modules are like eclipse land projects. here the idea is that you have one application project (module #3 in the list above) and several library projects(as separate modules under the global project folder (#1 in the above list)) which the application project depends on. how these library projects can be re-used in other applications, i still haven't found out.

[side note: the whole re-organization has some benefits like simplifications in src folder, but so many complications. the complications are mainly due very very thin documentation on this new project layout.]

the new build system

user guide for the new build system

explanation of flavors and buildtypes, etc - what is the hullabaloo about?

cheatsheet for flavors and buildtypes

buildtype: debug and release are buildtypes available by default on all projects. they are for building/compiling the same code to generate different apks. for example on release apks you would want to run proguard(for obfuscation), sign it with your key (as against the debug key), run optimizations (maybe via proguard or other tools), use slightly different packagenames (we use for release and for debug), etc. we also use a debug flag (buildconfig.debug) to turn off logging to logcat (since it makes the app slow) on release builds. this makes for a faster debug build during development but also an optimized release build to put on play store.

product flavor: there are no default flavors available (or to be precise, the default flavor is blank/nameless). flavors could be free version or paid version where they have different code. they share the same main code but different versions(or no versions) of a few source code files or resources.

buildvariant: a buildvariant is what a generated apk actually corresponds to. they are named like so (in order) product flavor + build type = build variant.
example 1: if you have free and paid as two flavors. the build variants you would get are:
free - debug
free - release
paid - debug
paid - release
so that is 4 possible apk configurations. a few configurations may not make sense in a particular project, but they are available.

example 2: (for new projects/ no flavors) you have 2 buildvariants or apks available, since the default flavor is nameless/blank:

compare this with intellij's project structure if that helps:

intellij project structure snapshot

the .idea (1) folder contains a number of subfolders, mainly with internal intellij idea information.

the src (2) folder contains the (3) file source code that implements the functionality of your application. the file belongs to the com.example package.

the res (4) folder contains various visual resources.

the layout/main.xml file (5) defines the appearance of the application constituted of resources of various types.

the values folder (6) is intended for storing .xml files that describe resources of various types. presently, the folder contains a strings.xml file with string resources definitions. as you will see from the adding a color section, the layout folder can also contain, for example, a descriptor of colors.

the drawable folder (7) contains images.

the gen (8) folder contains the (9) file that links the visual resources and the java source code. as you will see from the sections below, intellij idea supports tight integration between static resources and as soon as any resources are added or removed, the corresponding classes and class fields in are automatically generated or removed accordingly. the file also belongs to the com.example package.


for android studio 3.0.1 and selected all features:

  • android o latest
  • android auto
  • android things
  • android wear
  • android tv
  • c++ support
  • kotlin support

the structure in version 3.0.1 does not look at all like all other answers.

recent structure is as displayed in 2018, android studio 3.0.1 01/2018.

newbie kinda found something resembling to usable in feature sub-folder:

update your android studio 3.0.1 01_2018:



google discontinue the support for the android developer tools (adt) in eclipse is ending, per our announcement. you should migrate your app development projects to android studio as soon as possible. for more information on transitioning to android studio, see migrating to android studio.

so best for android development tool for android studio only for all future support of android m ---


android studio: app\build\source\r\debug\\

why are these paths different? why is my located in a debug folder in android studio? this lead to some errors early on, and if anyone has any insight into these differences i would appreciate them.

simply put, android studio is configured to build a debug build type on your system.

eclipse/adt is designed to support a single build at a time (from what i can tell). one of the primary goals of the new build system (from the user guide):

make it easy to create several variants of an application, 
either for multi-apk distribution or for different flavors of an application

so where as eclipse/adt could generate one file, android studio supports multiple. the generated is located in the debug folder because by default the new build system supports debug and release build types off the bat. if you changed your build variant (button, lower left hand corner of as) to release as will generate in the release directory.

this might not mean anything for simple projects, but the support of build variants means a drastic simplification of the build process for many developers, including the project i'm working on.

our project supports 4 flavors with 2 build types (debug and release), to support a total of 8 different apk combinations. and each of those combinations have slightly different configurations, so this build system really worked out for us. my android studio is installed on a different machine, but if memory serves my correctly the file exists in build/source/<flavor>/r/<build type>/package/ when our ci server builds the apk files it uses each of these files to generate separate packages.

Related Query

More Query from same tag