Tuesday, 26 May 2015

Android Environment Setup and basic code

Android Studio is a slightly heavy app, even in a machine with reasonable specs it sometimes hangs, yet that would do the job, just don’t run too many applications while you are working with studio. Moving on, I will first talk about the system requirements which would be any modern system with at least 2.5+GHz processor , a 4 Gb or above RAM(this is the minimum, please don’t  go below this it will kill your system).
However, for Linux users, it is recommended to install Studio in 64 bit systems. But to install Studio which is a 32 bit application in a 64 bit machine you need to have the 32-bit support library package ia32-libs.
For Ubuntu users, you can execute the below command:
sudo apt-get install ia32-libs
1)      Install Java Development Kit(JDK)
Download  and install the required JDK package from the below link which is apt for your system OS.
For windows , the JAVA_HOME environment variable. The steps of which are:
  1. Open My Computer.
  2. Go to System Properties.
  3. Open Advance system settings.
  4. Goto Advanced Tab and Open Environmental Variables.
  5. Then Click on New and Set Variable Name : Path and Set Variable Value : C:\Program Files (x86)\Java\jdk1.7.0_25\bin (The Directory In which JDK is installed.)
  6. Click OK
Verify the JDK installation by typing
java -version
from the command prompt, it should output
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)
If it works properly, else it will show command not found error
Install Android Studio
Install Android  Studio from the below link
Go through the license agreement and download the file as exe or zip. Install the exe file or unzip the zip file.
Run Android Studio, for the very first run you will get a dialog prompting  to import settings from an existing installation, followed by the setup guide.  Go through the guide and in the end press the finish button.
On starting Studio, you will be greeted with a welcome screen as follows

If you have already created projects it will be listed in the Recent Projects tab.
Now starting fresh,  click on the Start a new Android Studio project  and go through the guide. 

You can give your project a name say “HelloWorld” in camel case in the Application name field, also give a proper package name say ”com.example.firstproject.helloworld” in lower case, click next.

Select your desired platform, say you are developing a mobile app, select phone and tablet and also choose the minimum sdk version as to which version of android release can support your app(its advised to choose the lowest version, so that you app may run in most devices), click next.



Select a template, say Blank Activity. An activity is a code to support the UI. It will help you to design your application to behave as you wish in each lifecycle of the application like when the app is in foreground or background etc. The next page allows you to name your project components such as your activity, layout (a layout is view design on how you want to see each activity in your device), click Finish.

The android studio opens up with a layout displayed in front of you. You can see it contains a view with a label “Hello World”. In android all activity layouts by default comes up this way, so for now just click the play button on top if you have a device plugged in.
To run in emulator
·         Select Tools>Android>AVD Manager or click the icon https://developer.android.com/images/tools/avd-manager-studio.png in the toolbar.
·         Click Create Virtual Device
·         Select a device configuration say Nexus 6 and click next.
·         Select the version of the AVD
·         Click Finish
Once the emulator is launched and the home screen appears (it may take a while, have patience) click the run button from the toolbar and you can see the Hello World in your screen.






No comments:

Post a Comment