Saturday, December 25, 2010

Setting up toolchain for developing applications for Android on a Windows PC

Operating System: Windows 7 Ultimate 64 bit
  1. Download "Java Platform,Standard Edition JDK" (filename: jdk-6u23-windows-i586.exe) from http://www.oracle.com/technetwork/java/javase/downloads/index.html
    When asked to select the platform, select "Windows" and not "Windows x64" because we want the 32 bit software and not the 64 bit one eventhough our OS is 64 bit.
    No special installation instruction, just keep clicking next on the installation wizard dialog boxes that pop up.
  2. Download "Eclipse IDE for Java Developers" (filename: eclipse-java-helios-SR1-win32.zip) from http://www.eclipse.org/downloads/
    Use the 32 bit Eclipse eventhough your OS is 64 bit.
  3. Extract the folder "eclipse" from within eclipse-java-helios-SR1-win32.zip to C:\
    Rename this "eclipse" folder to "eclipseandroid" in case you want to distinguish it from other installations of eclipse.
  4. Run C:\eclipseandroid\eclipse.exe
  5. Rename the workspace path from "C:\Users\Anurag Chugh\workspace" to "C:\Users\Anurag Chugh\androidworkspace" and before pressing "OK" check the box "Use this as the default and do not ask again"
  6. Close Eclipse. Check the box "Always exit without prompt" before pressing "OK"
  7. Download "Android SDK Starter Package" (filename: installer_r08-windows.exe") from http://developer.android.com/sdk/index.html
  8. Install installer_r08-windows.exe. No special installation instruction, just keep clicking next on the installation wizard dialog boxes that pop up. At the end uncheck the box to prevent running the "SDK Manager" before clicking Finish.
  9. Create shortcut to "C:\eclipseandroid\eclipse.exe" on the Desktop and name it "Eclipse - Android"
  10. Download "ADT Plugin for Eclipse" (filename: ADT-8.0.1.zip) from http://developer.android.com/sdk/eclipse-adt.html
  11. Start Eclipse using shortcut placed on the desktop and go to Workbench.
  12. Click on "Help > Install New Software" .
  13. Click "Add"
  14. Click "Archive" and browse to point to "ADT-8.0.1.zip" and install everything related to Android. You will have to accept the license agreement before proceeding.
  15. Restart Eclipse when asked to do so.
  16. Close eclipse.
  17. From "Start Menu", right click "SDK Manager" listed under "Android SDK Tools" and click "Run as Administrator".
  18. Install all packages listed under "Android Repository". Select "Accept all" Radio button. Internet is required for this step. (takes lots of time to complete)
  19. If it throws an error, check the "Force https:// to be http://" checkbox listed under SDK Manager "Settings" and try again
  20. Within SDK Manager, go to Virtual devices and create a new "Android 2.3 - Level 9" Virtual device named "A2.3L9Hello". Set SD card Size to 64 MiB. Close the SDK Manager.
  21. Start Eclipse.
  22. Go to Window>Preferences>Android 
  23. Browse for SDK location and make it point to "C:\Program Files (x86)\Android\android-sdk-windows" and click Apply.
  24. Click OK and come out of the preferences.
  25. File>New>Project
  26. Select "Android Project" and click next.
  27. Project name: HelloWorld
  28. Build Target: Android 2.3 (API Level 9)
  29. Application Name: Hello, Android
  30. Package name: com.example.helloandroid
  31. Create Activity: HelloAndroid
  32. Click Finish
  33. Open HelloWorld>src>com.example.helloandroid>HelloAndroid.java
  34. Replace all the code in there with:

    package com.example.helloandroid;
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
    public class HelloAndroid extends Activity {
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           TextView tv = new TextView(this);
           tv.setText("Hello, Android");
           setContentView(tv);
       }
    }
  35.  Press the "Run" button (one with "Play" icon on it)
  36. When asked for a way to run the application select "Android Application"
  37. Whe asked to "Save Changes" click "Yes"
  38. Virtual device will boot up (takes lots of time). First textual animation appears and then Graphical Animation appears.
  39. When the home screen appears, the application will run and display "Hello Android". If it doesn't press the launcher icon on the screen (one with the small square grid on it) and run the "Hello, Android" application by click on its icon.
 
Explore Further:
http://developer.android.com/resources/tutorials/hello-world.html 

0 comments:

Post a Comment