Setup, configure and create an Android application in Android Studio

May 20, 2013
By

Android Studio is an official IDE ( Integrated Development Environment )  for Android application development which is announced in Google I/0 2013.



Android Studio is developed on the top of JetBrain’s Intellij IDEA a well known IDE for Java application development.

This article explains how to setup, configure and create an Android application in Android Studio IDE in the Linux distribution Ubuntu 12.04. This also explains some of the commonly occurred errors while working with Android Studio IDE.



Setting up Android Studio


1. Download Android Studio

We can download Android Studio from the given below link :

http://developer.android.com/sdk/installing/studio.html


2. Extract the downloaded file to /usr/local

$sudo tar -xvzf /usr/local/android-studio-bundle-130.677228-linux.tgz

3. Set the environment variable JAVA_HOME to installation directory of Oracle ( Sun )  Java Development Kit

$JAVA_HOME=/usr/java/jdk1.7.0_21
$export JAVA_HOME

Note : In order to set the environment variable permanently, add the above commands to the file [users_home]/.profile. 


4. Start Android Studio

We can start the Android Studio IDE by entering the given below commands :

$cd /usr/local/android-studio/bin
$./studio.sh

Import Settings Screen is shown in Figure 1 :

Import Settings

Figure 1 : Import Settings

Splash screen of the Android Studio is shown in the Figure 2 :

Starting up Android Studio IDE

Figure 2 : Starting up Android Studio IDE


Cnfiguring Android Studio


5. Configure Android Studio IDE

Click "Configure" in the Welcome Window

Figure 3 : Select "Configure" in the Welcome Window

Click "Project Defaults"

Figure 4 : Select "Project Defaults"

Select Project Structure

Figure 5 : Select "Project Structure"

Select Project SDK

Figure 6 : Select Project SDK

Select Build Target

Figure 7 : Select Build Target

Now click “Apply” and then “OK”


Creating a new Android Application Project in Android Studio


6. Select “Create Project” from Welcome dialog window

Select "New Project" from Welcome dialog window

Figure 8 : Select "New Project" from Welcome dialog window


8. Download Gradle Build System

For the first time, Android Studio will download and install Gradle build system, but may take some time

Download Gradle

Figure 9 : Download Gradle


9. Enter Project details

Enter Project details

Figure 10 : Enter Project details


10. Design application launcher icon

Design application launcher icon

Figure 11 : Design application launcher icon


11. Create a blank activity

Create a blank activity

Figure 12 : Create a blank activity


12. Enter MainActivity details

Enter MainActivity details

Figure 13 : Enter MainActivity details


13. Preview the application layout

Previewing the application layout

Figure 14 : Previewing the application layout


Creating an Android Virtual Device


14. Open AVD manager from the menu Tools -> Android->AVD Manager

Opening the AVD Manager

Figure 15 : Opening the AVD Manager


15. Create an AVD by clicking “Create” button in AVD manager dialog window

Creating an AVD

Figure 16 : Creating an AVD


Running the application


16. Choose Android Device

We can run the application from the menu “Run -> Run ‘HelloWorld-HelloWorld’

Choose Android Device

Figure 17 : Choose Android Device


17. Screenshot of the application in execution

Screenshot of the application in execution

Figure 18 : Screenshot of the application in execution


Download source code


18. Download source code


Common  Errors & Quick Fixes


19. ‘tools.jar’ is not in Android Studio classpath

'tools.jar' is not in Android Studio classpath

Figure 19 : Error : 'tools.jar' is not in Android Studio classpath

This error is usually occurs, if the environment variable JAVA_HOME is not set.

Please ensure that the Step 3 explained above is followed correctly.


20. Plugin com.intellij failed to initialize and will be disabled: null . Please restart Android Studio

Plugin com.intellij failed to initialize

Figure 20 : Error : Plugin com.intellij failed to initialize

This error may be fixed by installing Java Development kit in the path /usr/java


21.  Your Android SDK is out of date or missing templates. Please ensure you are using SDK version 22 or later.

Error : Your Android SDK is out of date

Figure 21 : Error : Your Android SDK is out of date

One of the method to fix this error is to configure the Android Studio ide as mentioned in the Step 5.


How to hire me?

I am George Mathew, working as software architect and Android app developer at wptrafficanalyzer.in

You can hire me on hourly basis or on project basis for Android applications development.

For hiring me, please mail your requirements to info@wptrafficanalyzer.in.

My other blogs
store4js.blogspot.com


Android Knowledge Quiz

Ready to test your knowledge in Android? Take this quiz :



Tags: , ,

2 Responses to Setup, configure and create an Android application in Android Studio

  1. Ra on April 20, 2014 at 2:01 am

    About step 19 – Error : ‘tools.jar’ is not in Android Studio classpath…
    Ill try to setur AndroidTools at WindowsXP64, and got this message too. By your notice i set environment variable JAVA_HOME to “C:\Program Files\Java\jdk1.8.0_05″ and add path to ..\jdk1.8.0_05\BIN folder into the PATH variable. That’s help.

  2. ayo on February 22, 2015 at 7:39 pm

    I running windows 8 64bit, I have set everything accordingly but I’m still stuck with “failed to load jvm.dll” I have a java_home already

Leave a Reply

Your email address will not be published. Required fields are marked *

Be friend at g+

Subscribe for Lastest Updates

FBFPowered by ®Google Feedburner