Set up Android Development Environment


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Set up Android Development Environment

  1. 1. CS241001 Android Lab 2009.11.24
  2. 2. <ul><li>Website </li></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><li>Android API </li></ul><ul><ul><li> </li></ul></ul>
  3. 3. <ul><li>Supported Operating Systems </li></ul><ul><ul><li>Windows XP (32-bit) or Vista (32- or 64-bit) </li></ul></ul><ul><ul><li>Mac OS X 10.4.8 or later (x86 only) </li></ul></ul><ul><ul><li>Linux (tested on Linux Ubuntu Dapper Drake) </li></ul></ul><ul><li>To get started, you’ll need to download and install the following Eclipse IDE </li></ul><ul><ul><ul><li>Eclipse 3.4 (Ganymede), 3.5(Galileo) </li></ul></ul></ul><ul><ul><ul><ul><li>Recommended Eclipse IDE packages: Eclipse IDE for Java EE Developers, Eclipse IDE for Java Developers, Eclipse for RCP/Plug-in Developers </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Eclipse JDT plugin (included in most Eclipse IDE packages) </li></ul></ul></ul></ul><ul><ul><ul><li>JDK 5 or JDK 6 (JRE alone is not sufficient) </li></ul></ul></ul><ul><ul><ul><li>Android Development Tools plugin (optional) </li></ul></ul></ul>
  4. 4. <ul><li>Download the latest JDK from Sun at </li></ul><ul><li>After installing JDK , remember to modify environment parameters “Path” </li></ul><ul><ul><li>C:Programming FilesJavajdk1.6.0_16in </li></ul></ul><ul><ul><li>C:Programming FilesJavajre6in </li></ul></ul>
  5. 6. <ul><li>Download Eclipse at </li></ul><ul><ul><li>Eclipse 3.4 (Ganymede), 3.5(Galileo) </li></ul></ul><ul><li>Uncompress the download file </li></ul>
  6. 7. <ul><li>Open Ecilpse </li></ul><ul><li>Select Help  Software Updates…  Available Software </li></ul><ul><li>In the resulting dialog box, choose “Add Site” </li></ul><ul><li>Enter the location </li></ul><ul><ul><li> </li></ul></ul><ul><li>Back in the Available Software view, you should see the plugin listed by the URL, with &quot; Developer Tools &quot; nested within it. Select the checkbox next to Developer Tools and click Install... </li></ul><ul><li>On the subsequent Install window, &quot; Android DDMS &quot; and &quot; Android Development Tools &quot; should both be checked. Click Next . </li></ul><ul><li>Read and accept the license agreement, then click Finish . </li></ul><ul><li>Restart Eclipse. </li></ul>
  7. 8. <ul><li>Download SDK from and uncompress </li></ul><ul><li>Now modify your Eclipse preferences to point to the Android SDK directory: </li></ul><ul><ul><li>Select Window -> Preferences... to open the Preferences panel </li></ul></ul><ul><ul><li>Select Android from the left panel. </li></ul></ul><ul><ul><li>For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory. </li></ul></ul><ul><ul><li>Click Apply , then OK . </li></ul></ul>
  8. 9. <ul><li>select Window  Android SDK and AVD Manager </li></ul><ul><li>Select  Available Packages  in the left panel. This will reveal all components currently available for download. </li></ul><ul><li>Select the components you'd like to install and click  Install Selected . </li></ul><ul><li>Verify and accept the components you want and click  Install Accepted . </li></ul>
  9. 12. <ul><li>Create an AVD </li></ul><ul><li>Create a New Android Project </li></ul><ul><li>Creating a Launch Configuration </li></ul><ul><li>Running and Debugging Your Android Applications </li></ul>
  10. 13. <ul><li>Create a virtual device </li></ul><ul><li>select Window  Android SDK and AVD Manager  Virtual Device  New </li></ul>Virtual Device name Select target Select skin Create  Finish
  11. 14. <ul><li>From Eclipse, select File > New > Project . </li></ul><ul><li>Select &quot;Android Project&quot; and click Next . </li></ul>
  12. 15. <ul><li>Fill in the project details with the following values: Project name: HelloAndroid </li></ul><ul><li>Build Target : Android 1.5 </li></ul><ul><li>Application name: Hello, Android </li></ul><ul><li>Package name: tw.nthu.cs241001.helloandroid </li></ul><ul><li>Create Activity: HelloAndroid </li></ul><ul><li>Min SDK Version: 5 </li></ul><ul><li>Click Finish </li></ul>
  13. 16. <ul><li>3 </li></ul>5 4 6 7 8 9
  14. 17. <ul><li>Select Run -> Run Configurations …. . </li></ul><ul><li>Right-click Android Application on the project type list, and select New. </li></ul>
  15. 18. <ul><li>Select Run As…  Android Application </li></ul>
  16. 19. <ul><li>src : This folder holds all the source code files for your application, inside the appropriate package subfolders. </li></ul><ul><li>gen : This file holds all the automatic generation files </li></ul><ul><li>res : This folder holds all the resources for your application. </li></ul><ul><li>AndroidMainifest.xml : list the application provide functions </li></ul>
  17. 20. <ul><li>package com.example.helloandroid; </li></ul><ul><li>import; </li></ul><ul><li>import android.os.Bundle; </li></ul><ul><li>public class HelloAndroid extends Activity { </li></ul><ul><li>/** Called when the activity is first created. */ </li></ul><ul><li>@Override </li></ul><ul><li>public void onCreate(Bundle savedInstanceState){ </li></ul><ul><li>super.onCreate(savedInstanceState); </li></ul><ul><li>setContentView(R.layout.main); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  18. 21. <ul><li>package com.example.helloandroid; </li></ul><ul><li>import; </li></ul><ul><li>import android.os.Bundle; </li></ul><ul><li>import android.widget.TextView; </li></ul><ul><li>public class HelloAndroid extends Activity { </li></ul><ul><li>/** Called when the activity is first created. */ </li></ul><ul><li>@Override </li></ul><ul><li>public void onCreate(Bundle savedInstanceState){ </li></ul><ul><li>super.onCreate(savedInstanceState); </li></ul><ul><li>// setContentView(R.layout.main); </li></ul><ul><li> TextView tv = new TextView(this); </li></ul><ul><li> tv.setText( “Test TextView” ); </li></ul><ul><li> setContentView(tv); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  19. 22. <ul><li>New String </li></ul><ul><ul><li>res  values  strings.xml </li></ul></ul><ul><ul><li>Click Add…  String  OK </li></ul></ul><ul><ul><li>Fill up Name and Value  Save </li></ul></ul><ul><li>Add to main.xml </li></ul><ul><ul><li>res  layout  main.xml </li></ul></ul><ul><ul><li>Select Text field </li></ul></ul><ul><ul><li>Properties </li></ul></ul><ul><ul><ul><li>Property : Text  Value  Select the new string </li></ul></ul></ul>