Android application development is never been easy due to its raw nature and rapid growth and changes to platform. If we cast our memories back a few years, Eclipse was the only IDE used for android development. Eclipse is developed and maintained by open source alliance. Due to its open source and free nature, it always failed to match its all time competitor platform IDE like XCode.
But now android development looks very promising with the introduction of Android Studio IDE. Android Studio is an IDE based on IntelliJ IDEA that is used for android application development. The initial developer preview was released on 15th may 2013. This tool has more options that will enable developers to speed up application development. In the later section of this tutorial we will understand the Android Studio project structure in context to traditional eclipse based project structure.
Checkout the related tutorial that might interest you.
Gradle Based Build System
- Android Studio is an IDE based on IntelliJ IDEA that uses gradle build system. In eclipse, you can create only one build at a time. Which means, first create debug build and later you can create a release build by signing with your keystore.
- Android Studio projects are setup to build both a debug and a release version of the application. The debug version is signed with the developer key store key which is created automatically (Same as eclipse debug builds). The release is not signed during the build, this needs to happen after.
- Android Studio, make it easy to create several variants of an application, either for multi-apk distribution or for different flavors of an application. This means, you can have different builds for debug, release or may be different variant build from the same code.
- Eclipse ADT plugin, always generate single R.java file but, Android Studio supports multiple. The generated R.java is located in the debug folder. You can change your build variant between debug and release and accordingly it will create the R.java file in selected debug or release directory.
Change the build type configuration here from the bottom left corner in your android Studio.
Android Studio Project Structure
1. Main Project
This would be entire project context. 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. A project in Android Studio is like a workspace in Eclipse. In android Studio a project, can contain multiple modules. A module in Android Studio is like a project in Eclipse. In the above screenshot “LoginAuthenticator” is the name of my project
This means that, in theory it is possible to build multiple apps with in the same project. From my personal experience, creating multiple apps with in the same project doesn’t works well. So, I recommend not to make your hands dirty trying the same thing. Instead, It is a better idea to create single app per single project.
Eclipse uses project.properties file for project specific metadata. Here in android studio, this .idea does the same thing. This means the project specific metadata is stored by Android Studio.
3. Project Module (app)
This is the actual project folder where your application code resides. The application folder has following sub directories
a. 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 R.java is found here under build/source/r/<build variant>/<package>/R.java
b. libs : This is a commonly seen folder in eclipse land too, which optionally can hold the libraries or .jar files.
c. src: The src folder can have both application code and android unit test script. You will find two folders named “androidTest” and “main” correspond to src folder. The main folder contains two subfolders java and res. The java folder contains all the java codes and res contains drawables, layouts, etc.
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 and information on targeted platform SDK is shown.