Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse.

Similar presentations


Presentation on theme: "The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse."— Presentation transcript:

1 The Android Development Environment

2  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse IDE  The Android emulator  Debugging Android applications  Other tools

3  See:  developer.android.com/sdk/index.html#quickstart  Software to download & install 1. Java Development Kit (JDK) 2. Eclipse IDE 3. Android SDK starter package 4. Eclipse ADT plugin 5. Add Android platform & other comps to SDK

4  Download Java Development Kit  www.oracle.com/technetwork/java/javase/downloads/ind ex.html

5  Preferred IDE, but you can use others  Requires version 3.5 or higher  Eclipse Classic recommended  http://www.eclipse.org/downloads/

6  Core tools needed to get started  developer.android.com/sdk/  Unpack files to a directory of your choice  By default: android-sdk-  Add this directory to your path to use Android tools from the command line

7  Download the ADT plugin  Use the Help -> Install New Software function  URL for Eclipse 3.5+ ▪ https://dl-ssl.google.com/android/eclipse/ https://dl-ssl.google.com/android/eclipse/  In the Available Software dialog, select the checkbox next to Developer Tools and click Next  Configure plugin  Open preferences, click on “Android” and set the SDK location

8  Launch the Android SDK and AVD Manager  Select at least the latest platform (2.3)

9  An Android Virtual Device (AVD) is a configuration of emulator options  An AVD includes:  A hardware profile  A platform  Other options ▪ e.g., emulator skin, screen dimensions, SD card size  A storage area  Create using Android SDK and AVD Manager tool

10  Start Eclipse  Create a new Android Project

11  Project name: HelloAndroid  Application name: Hello, Android  Package name: course.examples  Create activity: HelloAndroid  Min SDK: 9

12 package course.examples; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroid extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); }

13  Applications can run in an emulator  Advantages  Fast turnaround  Doesn’t require an actual phone  Uses faster CPU on emulation computer  Disadvantages  Some features unavailable ▪ e.g., no support for bluetooth or USB connections  Performance & user experience can be misleading

14  Emulates telephone calls & SMS messages % telnet localhost 5554 > sms send 5554 “This is a text message”  Will emulate typical speeds & latencies for different networks (e.g., edge, gprs, etc.) % telnet localhost 5554 > set speed gprs  Can interconnect multiple emulators % emulator -avd Android_2.2_primary % emulator -avd Android_2.2_secondary  In one dialer app, dial port num of other emulator

15  Many more options  See: developer.android.com/guide/developing/tools/e mulator.html

16

17

18  Can also add trace code into your application // start tracing to "/sdcard/calc.trace" Debug.startMethodTracing("calc"); … // stop tracing Debug.stopMethodTracing();  Will need to set permissions (discussed later) <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE />

19  To view results after execution % adb pull /sdcard/calc.trace /tmp % traceview /tmp/calc

20

21  Log viewer  Android logs many events by default  Can use android.util.Log & android.os.Debug class for application-specific logging  View log entries with  % adb logcat  Or inside Eclipse  Window -> Show View -> Other -> Android -> LogCat

22  Visual representation of application UI % hierarchyviewer

23

24

25  Sends psuedorandom events to applications  Can also script events with monkeyrunner API // send event to browswer % adb shell monkey -p com.android.browser -v 500 // send events to all applications % adb shell monkey 500

26  Android-specific extensions to Junit  MoreAsserts  Additional result checking classes  ViewAsserts  Asserts about view layout  TouchUtils  Classes for generating touch events  Instrumentation  For monitoring application interaction with system

27  Steps for testing Activity  Create an Android test project  Create one or more Android test classes ▪ Add code to each Test class  Test code usually includes test methods for  App initialization  UI behavior & class functionality  Application lifecycle state management

28  AndroidTestCase  Test case with access to Activity Context  ActivityUnitTestCase ▪ isolated testing of a single activity  InstrumentationTestCase  Test case with access to system instrumentation & events  ActivityInstrumentationTestCase2 ▪ functional testing of a single activity  Many other test case types  developer.android.com/guide/topics/testing/testing_a ndroid.html

29  Junit Test flow  setup()  Put application in known state  run()  Create additional data  Execute method under test  Check result with Assert  tearDown()  Return to known state

30  developer.android.com/resources/tutorials/te sting/activity_test.html

31  Key steps  Declare your application as "debuggable" in your Android Manifest  Turn on "USB Debugging" on your device  Setup your system to detect your device  See:  developer.android.com/guide/developing/device. html

32


Download ppt "The Android Development Environment.  Getting started on the Android Platform  Installing required libraries  Programming Android using the Eclipse."

Similar presentations


Ads by Google