Tuesday, 18 September 2012

How to Install the Android SDK on Windows XP and Create an Application that Runs in the Cell Phone Emulator:

1. Download and Install the Android SDK and Test the Emulator

2. Install Java 
3. Install Eclipse 
4. Install the ADT Plugin in Eclipse  
5. Create Hello World Applicatio

1. Download and Install the Android SDK and Test the Emulator


We will first go to the Android site and download the SDK
1.
Goto code.google.com/android/download.html and click on theandroid_sdk_windows... link.
download link

2.
Unzip the SDK where you downloaded it.
unzip sdk
post comment or question
3.
Copy all unzipped files to c:\android.
to c android
post comment or question
4.
Set your PATH environment variable by doing this: start > settings >control panel > system > advanced > environmental variables , in theSystem Variables box, click Path and the  Edit  button, then go to the end of you PATH variable, and type ;c:\android\tools and then click  OK  ,  OK  ,  OK  .
android path
post comment or question
5.
Click on start > programms > accessories > command prompt and typeemulator and hit  ENTER  , in a couple seconds the emulator will appear, leave the check checked and click  Proceed .
emulator show
aaronferrucci: If your computer is old/slow, it may take a while for the emulator to come up. Enjoy the cylon display while you wait.
arrow pointing right
reply
Joe: In my command prompt, I get an error message "Cannot create data directory: .... please specify a writable directory with -datadir. Any help?
arrow pointing right
Jeff: I was able to get it working by specifying a directory via -datadir I used c:\android\temp\
arrow pointing right
Paul: Me too... I created them manually, which allowed the emulator to start, but all it says is "A N D R O I D " and won't do anything else...
arrow pointing right
David: Paul I have the exact same thing, any work arounds?
arrow pointing right
Girish: I created a temp dir. But still tat doesnot work
arrow pointing right
Girish: it says "A N D R O I D " and and i cant use anything else...
arrow pointing right
Jim: I did this as well it got to the "A N D R O I D" part. I had to wait about 1 full min for it to respond. It did.
arrow pointing right
NAF: I got the same 'ANDROID' display. But after waiting a while, my app finally ran (I got Core 2 Duo 1,8GHz). Maybe just be a little patient, it takes some time.
arrow pointing right
Jess: I'm still not sure how you create them manually could i get someone to explain a little more? thanks
arrow pointing right
jess: I mean I got c:\android\tools but i still don't know where to go from there to get the emulator.exe to run
arrow pointing right
Hamed: for the error in command prompt ""Cannot create data directory: .... please specify a writable directory with -datadir." I created the directories mentioned in the path above this error manually. for example the path for me was like this: "C:\Documents and Settings\Administrator\Local Settings\Application Data\Android\SDK-1.0" then u just need to go to MyComputer and follow this path "C:\Documents and Settings\Administrator\Local Settings\Application Data\" then there creat the new folder "Android", go to Android folder and creat the new folder "SDK-1.0" . then just go to command prompt and type emulator. it worked for me like this and the Android Emulator appeared on the screen. but u have to wait a little bit till the menu appear after android logo. hope this helps :)
arrow pointing right
sikus: I did in folder "SDK-1.0" .bat file and there I wrote "-datadir C:\android\". This is folder where I have unzip SDK for Android.
arrow pointing right
reply
PW: Jess: Create them manually in the command prompt by typing the following: C:\>emulator -datadir c:\android\temp reply
post comment or question
6.
Click on the browser button.
click browser
post comment or question
7.
Click on the "quick links" icon and press  a .
click quick links
post comment or question
8.
Type in a website address you want to view and press  ENTER .
view it
post comment or question


2. Install Java
To run Eclipse we first need Java so we will download and install it now.
1.
Goto developers.sun.com/downloads.
sun site
Stone Deft: At this point apache mysql and phpmyadmin is already installed and you can skip this step if you prefer to use dreamweaver or other php editors other than eclipse
arrow pointing right
reply
post comment or question
2.
Click on the Java SE (JDK) 6 link.
download jdk
uninstall: I have 2 java programs running and I can't uninstall one of them because it says there was a fatal error when installing it
arrow pointing right
reply
Joel: I'm pretty sure you only need a JRE to run Eclipse, not the full JDK.
arrow pointing right
BitJunky: JDK 5 or JDK 6 (JRE alone is not sufficient) http://code.google.com/android/intro/installing.html
arrow pointing right
reply
post comment or question
3.
Click on the  Download  button for JDK 6u1.
jdk6u1
krisavi: I clicked it and it gives me that download server is down, where I can download JDK 6u1 then?
arrow pointing right
Edward: I just tried it and got "Notice: We're Offline for System Upgrades" as well. Just wait a bit and try again.
arrow pointing right
reply
Ward Christensen: Only offers 6u2 07/08/07. 6u1 SDK EE stilll there. I'm going to DL 6u2 (and I was impressed how up-to-date all the comments so far have been!) This is WONDERFUL!
arrow pointing right
reply
Johnny: I can't find any 6u1 or 2 there.
arrow pointing right
student: i did the 6u4 one
arrow pointing right
himanshu: JDK 6 Update 6 is the latest. sincerely, Himanshu.
arrow pointing right
Hamed: if it has the explanation which says : "The Java SE Development Kit (JDK) includes the Java SE Runtime Environment (JRE) and command-line development tools that are useful for developing applets and applications." thats enough. for example i downloaded the Java SE Development Kit (JDK) 6 Update 10.
arrow pointing right
reply
lini: i cant find jdk 6u1
arrow pointing right
reply
steve: jdk-6u7-windows-i586-p.exe #sept-27th-08#
arrow pointing right
reply
Qn: JDK 6u7 the newest one.
arrow pointing right
reply
AH: i cant find jdk 6u1 either.
arrow pointing right
reply
post comment or question
4.
Click Accept.
click accept
post comment or question
5.
Click on Windows Offline Installation, Multi-language.
offline version
Chill: This is the message i get when i try to download it, "There are no 64-bit versions of the Java Plugin, Java Web Start or Java Control Panel; however the 32-bit versions of the JRE can be installed on 64-bit systems in order to obtain this functionality. Note that only 32-bit browsers are supported at this time." What to do now??? reply
post comment or question
6.
Click  OK  to save it to disk.
save to disk
post comment or question
7.
Save it to C:\download\java6.
download java6 directory
Johnny: You make a your own folder first right?
arrow pointing right
Edward: Right, the main thing is that you just download it somewhere and execute it.
arrow pointing right
reply
post comment or question
8.
Wait a couple minutes.
couple minutes download
post comment or question
9.
After it has finished downloading, you will have this file in your directory.
downloaded
post comment or question
10.
Double click on file that was downloaded.
click on download
Michael: I clicked it and I got 'To Restart Installer, Please Refresh The Webpage'
arrow pointing right
reply
Samantha: I also have the same problem.. reply
post comment or question
11.
Accept agreement.
accept agreement
post comment or question
12.
Click  Next  and it will install for about 8 minutes.
next installing
post comment or question
13.
Unclick the Show the readme file checkbox and click  Finish .
wizard completed
post comment or question



3. Install Eclipse
Eclipse is a professional editor normally used for Java. We will install it in this step and then install the PHPEclipse plugin so we can use it with PHP.

1.
Goto www.eclipse.org/downloads and click Eclipse IDE for Java Developers.
eclipse for java
Karl K: Hmmm... If I have Eclipse installed, having followed the PHP Quick Install tutorial, do I need to create a totally separate android (Java-based) development environment? The bundled packages seem to hinder creation of combined/hybrid eclipse installs.
arrow pointing right
Edward: Theoretically you could have one eclipse and just switch the perspectives between PHP and Java, but my experience is that conflicts occur. The great thing about eclipse is it is not INSTALLED per-se so you can just have a c:\eclipsePhp and a c:\eclipseAndroid and start the one you need, and you can even have both open at the same time, a nice feature.
arrow pointing right
reply
remish: i have already eclipse with me, only i want to add the android plugins but it is giving error of RCP.how i can resolve it? reply
post comment or question
2.
Click on the suggested mirror link.
pick eclipse mirror
post comment or question
3.
Click "Save to Disk" and click on  OK .
save eclipse
post comment or question
4.
Unzip the Eclipse file that you downloaded.
unzip eclipse
post comment or question
5.
Type in c:\ and click  OK  (this will create a directory called c:\eclipse and unpack everything there.
unzip to c
post comment or question
6.
Double-click on the file c:\eclipse\eclipse.exe.
start eclipse
post comment or question
7.
Set the workspace to C:\androidApps , click the checkbox, then click  OK .
android apps
post comment or question
8.
Click on the workbench icon.
goto workbench
Himanshu: Why this step may I ask ? You just tell to click here and then next step says to exit. just curious,
arrow pointing right
Jo: think about it
arrow pointing right
reply
russell adkins: Maybe to make sure it works?
arrow pointing right
reply
post comment or question
9.
Close Eclipse by clicking on the X.
close eclipse
post comment or question
10.
Click the checkbox and  OK .
close eclipse2
post comment or question



4. Install the ADT Plugin in Eclipse
This plug-in (Android Development Tools) will make creating applications for Android easier so we will install it now.

1.
Start Eclipse and then click Help > Software Updates > Find and Install....
find and install
Thakgatso: i dont have the "Find and intall.." option. I only have the Software Updates...The menu does not extend.
arrow pointing right
reply
Tapan: Even I don't see "Find and install" option. I only have the "Software Updates...." I have downloaded the latest Eclipse version 3.4 and installed. reply
Clement: The sub menus under Software Updates no longer shows Click on the available software tab Then click on add site Add: https://dl-ssl.google.com/android/eclipse You will see the two packages listed
arrow pointing right
Skipper: I get an error saying: No repository found at https://dl-ssl.google.com/android/eclipse
arrow pointing right
Skipper: fixed, just had to use "http" instead of "https"
arrow pointing right
reply
post comment or question
2.
Click the Search for new features to install choice and then click  Next .
search install
post comment or question
3.
Click the  New Remote Site...  button.
new remote site
post comment or question
4.
In the Name box type Android Plugin and in the URL box type https://dl-ssl.google.com/android/eclipse, then click  OK .
android plugin type
filbert: In Eclipse it results in the following error: No repository found at https://dl-ssl.google.com/android/eclipse/ In a browser it results in a 404. Changing to http:// makes no difference.
arrow pointing right
reply
post comment or question
5.
Make sure Android Plugin choice is checked and click  Finish .
check and finish
post comment or question
6.
Check the Android Pluging choice again and click  Next .
click android and next
Santhosh: After clicking on Next,i am getting an pop-up saying IO EXception.PLease provide a solution to my exception. reply
remish: when i am selecting the checkbox its showing the error "Current configuration problems". how i can resolve this. reply
post comment or question
7.
Check the I accept the terms in the license agreement choice and click  Next .
click i accept
post comment or question
8.
Click  Finish .
click finish now
post comment or question
9.
Click  Install All .
click install all
post comment or question
10.
Click  Yes  to restart Eclipse.
click yes restart
post comment or question
11.
When Eclipse starts again, click Window > Preferences....
windows preferences
Joel: The default font size really is fine if you're using a modern, high-res, monitor. If you're still in 1024x768, I can see why you'd want smaller characters though.
arrow pointing right
reply
indeed: this should perhaps been marked as optional? at 1920x1200 this will give me REALLY small letters xD reply
post comment or question
12.
Click Android then  OK .
android then ok
Francis Cagney: I've followed all these steps exactly to here, but at this point no android preferences appears on the left. If I try and re download android adt it say its already there. Below are the only tabs visible General C/C++ Help Install/Update Run/Debug Team
arrow pointing right
Francis Cagney: Actually I've solved it. I was download Ecliple for C++ instead of exclipse for java. Surprised some part of the Eclipse/android interaction dind't point out what was wrong. Still thanks to Edward Tanguay for writing a superb tutorial. Gonna enter the google competition?
arrow pointing right
Omar: Yeah Edward. Would like to know if you are planning to take part in the Android App Contest.
arrow pointing right
reply
selva: I dont get android preference on the left . someone please help me.
arrow pointing right
yogesh: I am getting the error when i enter path of tools for android. C:\android-sdk_m5-rc15_windows\tools [2008-03-17 01:51:40 - adb] Failed to get the adb version: Cannot run program "\tools\adb.exe": CreateProcess error=3, The system cannot find the path specified [2008-03-17 01:52:21 - adb] * daemon not running. starting it now * Also i have observed that i am not getting check box automatic sync project to current SDK email :- yogeshsdsu@gmail.com . I am going to start working on a project on andoid. I will be thankfull if Edward .
arrow pointing right
reply
post comment or question
13.
Click  Browse...  then navigate to c:\android and click  OK .
browse and find
post comment or question
14.
Click  Apply  and then  OK .
apply ok
post comment or question

5. Create Hello World Application
This will show you how to make a simple application with Eclipse.
1.
Click File > New > Other....
file new other
post comment or question
2.
Click on Android Project and  Next .
android and next
post comment or question
3.
Fill out the form and click  Finish .
fill finish
post comment or question
4.
Change the code in HelloWorld.java to the following.
change code
pcor59: Hallo, with last SDK I had to modify java source with 2 import: import android.os.Bundle; import android.widget.TabTextView; and I had to replace TextView with TabTextView. All worked. Thank you very much for your great Tutorial, all the best and have a nice 2008.
arrow pointing right
Andy: Hi pcor59, I'm using the latest SDK. How do I modify java source with the 2 import you mentioned?
arrow pointing right
reply
Andy: Hi Edward! You site had very good tutorials! I'm using the latest SDK and I'm getting an error something like "TextView cannot be resolved to a type" pointing to line 10 of the code. I'm excited to see my first Hello World program. Appreciate your help!
arrow pointing right
Rod: I hope this isn't posted too late but I got the same error. The solution I accidentally happened upon: Adding the following under 'import android.app.Activity; ... import android.os.Bundle; import android.widget.TextView; This solved my problem... :-\
arrow pointing right
reply
Ronen: i just read on the notepad tutorial , that pressing ctrl+shift+o can automatically add missing imports for you. tried it here and it worked. so instead of writing import line you can press those keys. reply
post comment or question
5.
Click Run > Open Run Dialog....
open run dialog
post comment or question
6.
Click on Android Application, then on the add icon, fill in Name, Project and Activity and press Next .
six steps
post comment or question
7.
In about 20 seconds you will see your application appear in the emulator.
in emulator
KenR: Excellent tutorial. Thank you so much for making everything so easy to get started. You are the man!
arrow pointing right
Harpreet: Great tutorial to start , havent seen better than this
arrow pointing right
reply
Gaurav: Excellent Tutorial....All Done in really easy steps... :) reply
LC: Excellent, yes! verry easy! Now, since I am a greenie at this, please point me toward a site that will tell me what it is I just did??? I get the emulator, not sure about eclipse and what it means to create applications. Thanks much :) reply
judy: Superb Tutorial. reply
Vishal Singh: Awesome tutorial. But emulator is old. reply
ekambresh: Excellent tutorial i was facing lots of problem while installing eclipse with adt plugin. u made it easy thanks a lot.it will be better post some tutorial regarding android. reply
Hebs: Hey thanks for this tutorial. I tried all week to get the sdk working in Ubuntu 7.10 but failed. I am getting dependency errors when installing the ADT plugin in Eclipse. I guess this is one more thing I will have to restart to Windblows for : / reply
Rod: Amazing... I followed through and this worked! I am so happy I didn't crash and burn. :-) reply
sunny: very well put together and worked perfectly reply
mrbahl: Hello, Amazing tutorial Sir ! Good job.. you deserve a letter of thanks from the eclipse and google team. :-) reply
Thakgatso: Thanks for this tutorial, it helped me a lot. I dont seem to get the 4th step right. i cant get the Eclipse to install the android SDK from the Help>>Install updates reply
siddharth khimsara: a very good and easy to-the-point tutorial...hats off!! reply
Justin: Spot on - installation a bit dated, used this from Google http://code.google.com/android/intro/installing.html and then followed the Hello World tutroial here and it worked fine. Thanks very much! reply
Doctor: Great tutorial. Really helped me. reply
Mukaram: Thanks. Got me started in no time. reply
raykin: Thanks, very good tutorial. Saved me a lot of time. reply
Hamed: a really great and usefull step by step tutorial! tnx so much, keep it up :) reply
post comment or question

2 comments:

  1. The world of mobile phones is now under the grip of new technology pertaining to accessing the internet. Most of the smart phones that facilitate the surfing of the internet are Android based. This has led to the increase in demand of Android Applications.

    Thanks
    set up online shop

    ReplyDelete