M.Sc. Bui Tan Loc: Module 2: Getting Started With Android Development
Android Basic Course (c) 2012 University of Science - HCM City. Launching an Android application with different emulators corresponding different platforms About DDMS tools About changing xml resource file by GUI or Text editor. Completing this module, you will have learned: About installing the Android Development environment About Using SDK Manager and AVD manager.
M.Sc. Bui Tan Loc: Module 2: Getting Started With Android Development
Android Basic Course (c) 2012 University of Science - HCM City. Launching an Android application with different emulators corresponding different platforms About DDMS tools About changing xml resource file by GUI or Text editor. Completing this module, you will have learned: About installing the Android Development environment About Using SDK Manager and AVD manager.
. Module 2: Getting Started with Android Development M.Sc. Bui Tan Loc [email protected]
Department of Software Engineering, Faculty of Information Technology, University of Science Ho Chi Minh City, Viet Nam Android Basic Course 2012 University of Science HCM City . Objectives After completing this module, you will have learned: About installing the Android development environment About using SDK Manager and AVD Manager About Android project structure About launching an Android application with different emulators corresponding different platforms About DDMS tools About how to debug an application About changing xml resource file by GUI or Text editor. 2 Android Basic Course 2012 University of Science HCM City . Contents Getting to install the Android development environment Getting to know Android SDK tools Getting to know Android project structure Getting to know how to run with the default emulator Getting to know how to run with the specified emulator Getting to know DDMS tools Getting to know how to debug with the default emulator Getting to know how to change xml resource files
3 Android Basic Course 2012 University of Science HCM City . Getting to install the Android development environment Supported OS: Windows, Mac OS X, Linux Pre-requirement: JDK 1. Installing Editor: Eclipse (Eclipse classic version is recommended) 2. Installing SDK Starter Package (SDK Manager): Note that you need to refer to the SDK directory (In Windows OS, this called set path) 3. Installing ADT plugin for Eclipse: Configuring Eclipse to work with SDK Manager 4. Using SDK Manager to add platforms and other components: SDKs, documents, sample source codes, etc. 4 Android Basic Course 2012 University of Science HCM City . Installing JDK http://www.oracle.com/technetwork/java/javase/downlo ads/index.html Ex: The installation directory is c:\Program Files\Java\ The JDK folders path is c:\Program Files\Java\jdk1.6.0_17 5 Android Basic Course 2012 University of Science HCM City . Installing Eclipse Editor http://www.eclipse.org/downloads/ Ex: The installation directory is d:\Program Files\ The Eclipse folders path is d:\Program Files\eclipse\ At the first time launching Eclipse, you must select a workspace folder to store your projects. Ex: The workspace folder is d:\Program Files\eclipse\workspace\ You can change workspace folder at any time you want. Ex: File > Switch workspace > Other 6 Android Basic Course 2012 University of Science HCM City . Installing SDK starter package (SDK Manager) http://developer.android.com/sdk/index.html Ex: The installation directory is d:\Program Files\Android\ The SDK folders path is d:\Program Files\Android\android-sdk- windows\ 7 Android Basic Course 2012 University of Science HCM City . Installing ADT plugin for Eclipse http://developer.android.com/sdk/eclipse- adt.html#installing Start Eclipse, then select Help > Install New Software.... Click Add, in the top-right corner. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/ Click OK Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons). In the Available Software dialog, select the checkbox next to Developer Tools and click Next. In the next window, you'll see a list of the tools to be downloaded. Click Next. Read and accept the license agreements, then click Finish. Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK. When the installation completes, restart Eclipse 8 Android Basic Course 2012 University of Science HCM City . Updating the ADT Plugin Want to update the ADT plugin, see more : http://developer.android.com/sdk/eclipse-adt.html#installing 9 Android Basic Course 2012 University of Science HCM City . Installing ADT plugin for Eclipse 10 Android Basic Course 2012 University of Science HCM City . Configuring Eclipse to work with SDK Manager Start Eclipse, then Select Window > Preferences... to open the Preferences panel (Mac OS X: Eclipse > Preferences). Select Android from the left panel. You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and click Proceed. You cannot continue with this procedure until you click Proceed. For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory. Click Apply, then OK. 11 Android Basic Course 2012 University of Science HCM City . Configuring Eclipse to work with SDK Manager 12 Android Basic Course 2012 University of Science HCM City . Getting to know Android SDK tools SDK Manager is used for adding platforms and other components. Start Eclipse, then Select Android SDK Manager Or launch SDK Manager.exe in Android SDK folder AVD (Android Virtual Device) Manager is used for creating emulators corresponding to the selected platforms. Start Eclipse, then Select AVD Manager Or launch AVD Manager.exe in Android SDK folder
13 Android Basic Course 2012 University of Science HCM City . Using SDK Manager to add platforms and other components 14 Android Basic Course 2012 University of Science HCM City . Using AVD Manager to create a new emulator 15 Android Basic Course 2012 University of Science HCM City . Testing your development environment If above things are be ready-to- work. You will run the HelloWorld Application successfully. http://developer.android.com/res ources/tutorials/hello-world.html 16 Android Basic Course 2012 University of Science HCM City . Getting to know project structure contains java source files is generated when res folder is modified is selected platform to build the application is application package that will be installed on emulators or real devices are image resources describes UI components describes string constant values is an application configuration file 17 Android Basic Course 2012 University of Science HCM City . Getting to know how to switch platform Right click the project root, then select Properties > Android > select the platform you want. 18 Android Basic Course 2012 University of Science HCM City . Getting to know how to run with the default emulator Run application with the default emulator Right click project, then select Run As > Android Application 19 Android Basic Course 2012 University of Science HCM City . Getting to know how to run with the specified emulator Run application with the specified emulator Right click project, then select Run As > Run Configurations > select the specified emulator 20 Android Basic Course 2012 University of Science HCM City . Getting to know how to run with the specified emulator 21 Android Basic Course 2012 University of Science HCM City . Getting to know DDMS tools The ADT plug-in in Eclipse provides some useful tools to control your Android Emulator. In Eclipse, click on the Open Perspective button and select DDMS or select Other/DDMS. 22 Android Basic Course 2012 University of Science HCM City . Overview DDMS Tools 23 Android Basic Course 2012 University of Science HCM City . Overview DDMS Tools 24 Android Basic Course 2012 University of Science HCM City . Getting to know how to debug with the default emulator 25 Debug application with the default emulator Right click project, then select Debug As > Android Application Select Yes to open Debug Perspective Android Basic Course 2012 University of Science HCM City . Insert breakpoint 26 Android Basic Course 2012 University of Science HCM City . Debug tools 27 Run/Resume Suspend Terminate Step Into Step Over Step Return Android Basic Course 2012 University of Science HCM City . Debug tools 28 Viewing variables in a function automatically Viewing specified variables in a function Android Basic Course 2012 University of Science HCM City . Getting to know how to change xml resource file: main.xml, string.xml, and AndroidManifest.xml There are two ways to change these xml files: Using text editor Using GUI editor 29 Android Basic Course 2012 University of Science HCM City . Ex: Using text editor to change main.xml 30 Android Basic Course 2012 University of Science HCM City . Ex: Using GUI editor to change main.xml 31 Android Basic Course 2012 University of Science HCM City . Questions or Discussions How to install a new Android platform How to create an Android emulator How to run an Android application with different emulators corresponding different platforms How to emulate voice calls, SMS messages, and GPS functionalities How to debug an Android application with different emulator corresponding different platforms How to modify xml files in the Android project
32 Android Basic Course 2012 University of Science HCM City . References & Further Readings Installing the SDK: http://developer.android.com/sdk/installing.html Getting Started with Android Development: http://mobiforge.com/developing/story/getting-started-with- android-development Managing AVDs with AVD Manager: http://developer.android.com/guide/developing/devices/managing- avds.html Managing AVDs from the Command Line: http://developer.android.com/guide/developing/devices/managing- avds-cmdline.html Using the Android Emulator: http://developer.android.com/guide/developing/devices/emulator.h tml 33 Android Basic Course 2012 University of Science HCM City . References & Further Readings Creating an Android Application using the Eclipse Plugin http://developer.android.com/resources/faq/commontasks.html#n eweclipseandroidproject Adding an External Library (.jar) using Eclipse http://developer.android.com/resources/faq/commontasks.html#a ddexternallibrary Referring to localhost from the emulated environment http://developer.android.com/resources/faq/commontasks.html#lo calhostalias 34