SELP: Debugging, AVDs and Manifests

73
Software Engineering Large Practical Debugging Android Applications, working with Android Virtual Devices, and Manifests Stephen Gilmore School of Informatics, University of Edinburgh October 10th, 2012 Stephen Gilmore Software Engineering Large Practical

description

Software Engineering Large Practical: Debugging Android Applications, working with Android Virtual Devices, and Manifests

Transcript of SELP: Debugging, AVDs and Manifests

Page 1: SELP: Debugging, AVDs and Manifests

Software Engineering Large Practical

Debugging Android Applications,working with Android Virtual Devices,

and Manifests

Stephen Gilmore

School of Informatics, University of Edinburgh

October 10th, 2012

Stephen Gilmore Software Engineering Large Practical

Page 2: SELP: Debugging, AVDs and Manifests

Eclipse DDMS perspective

The Dalvik Debug Monitor Server (DDMS) is a debugging tool forAndroid. It provides port-forwarding services and screen capture onthe device. It provides information about process, threads andheap usage. It contains the logcat console which allows us to seediagnostic error messages. It allows the developer to simulate theeffect of an incoming call or SMS, or to simulate setting thephone’s location.

Stephen Gilmore Software Engineering Large Practical

Page 3: SELP: Debugging, AVDs and Manifests

DDMS perspective in Eclipse

shot 2011-09-29 at 12.05.14.png

Stephen Gilmore Software Engineering Large Practical

Page 4: SELP: Debugging, AVDs and Manifests

Set your location

shot 2011-09-29 at 12.03.05.png

Stephen Gilmore Software Engineering Large Practical

Page 5: SELP: Debugging, AVDs and Manifests

LogCat — a log of events on the phone

shot 2011-09-29 at 12.06.56.png

Stephen Gilmore Software Engineering Large Practical

Page 6: SELP: Debugging, AVDs and Manifests

File Explorer — see files on the phone

shot 2011-09-29 at 12.07.32.png

Stephen Gilmore Software Engineering Large Practical

Page 7: SELP: Debugging, AVDs and Manifests

Devices — see processes in the emulator

shot 2011-09-29 at 12.10.14.png

Stephen Gilmore Software Engineering Large Practical

Page 8: SELP: Debugging, AVDs and Manifests

Allocation tracker

shot 2011-09-29 at 12.10.28.png

Stephen Gilmore Software Engineering Large Practical

Page 9: SELP: Debugging, AVDs and Manifests

Creating an Android Virtual Device

An Android Virtual Device (AVD) is an emulator configurationwhich allows the developer to replicate the effect of having anactual Android device such as a phone or a tablet. The AVD allowsyou to specify hardware and software settings which will beemulated by the Android Emulator. When creating a new AVD youspecify the target API (i.e. a particular version of Android).

Stephen Gilmore Software Engineering Large Practical

Page 10: SELP: Debugging, AVDs and Manifests

Creating an emulator

shot 2011-09-29 at 12.13.31.png

Stephen Gilmore Software Engineering Large Practical

Page 11: SELP: Debugging, AVDs and Manifests

Android Virtual Device (AVD) manager

shot 2011-09-29 at 12.13.40.png

Stephen Gilmore Software Engineering Large Practical

Page 12: SELP: Debugging, AVDs and Manifests

Create a new AVD (Click New...)

shot 2011-09-29 at 12.14.01.png

Stephen Gilmore Software Engineering Large Practical

Page 13: SELP: Debugging, AVDs and Manifests

Create new Android Virtual Device

shot 2011-09-29 at 12.21.54.png

Stephen Gilmore Software Engineering Large Practical

Page 14: SELP: Debugging, AVDs and Manifests

Starting the emulator

Having defined the type of AVD that we are interested in, we canstart one running and investigate the functions of our virtualdevice.

Stephen Gilmore Software Engineering Large Practical

Page 15: SELP: Debugging, AVDs and Manifests

Start the new AVD

shot 2011-09-29 at 12.22.07.png

Stephen Gilmore Software Engineering Large Practical

Page 16: SELP: Debugging, AVDs and Manifests

Launch Options

shot 2011-09-29 at 12.22.18.png

Stephen Gilmore Software Engineering Large Practical

Page 17: SELP: Debugging, AVDs and Manifests

Emulator launches ...

shot 2011-09-29 at 12.23.31.png

Stephen Gilmore Software Engineering Large Practical

Page 18: SELP: Debugging, AVDs and Manifests

Emulator home page is displayed

shot 2011-09-29 at 13.03.13.png

Stephen Gilmore Software Engineering Large Practical

Page 19: SELP: Debugging, AVDs and Manifests

Click to display options

shot 2011-09-29 at 13.03.14.png

Stephen Gilmore Software Engineering Large Practical

Page 20: SELP: Debugging, AVDs and Manifests

Functions of the phone

shot 2011-09-29 at 13.03.57.png

Stephen Gilmore Software Engineering Large Practical

Page 21: SELP: Debugging, AVDs and Manifests

Developer tools

There are some tools on the device which are specifically there tohelp developers (API Demos and Dev Tools). The developer toolsallow us to see (for example) processes which are running on thephone.

Stephen Gilmore Software Engineering Large Practical

Page 22: SELP: Debugging, AVDs and Manifests

Useful functions

shot 2011-09-29 at 13.11.56.png

Stephen Gilmore Software Engineering Large Practical

Page 23: SELP: Debugging, AVDs and Manifests

Developer Tools

shot 2011-09-29 at 13.04.23.png

Stephen Gilmore Software Engineering Large Practical

Page 24: SELP: Debugging, AVDs and Manifests

Running processes

shot 2011-09-29 at 13.05.16.png

Stephen Gilmore Software Engineering Large Practical

Page 25: SELP: Debugging, AVDs and Manifests

API demosThere are some tools on the device which are specifically there tohelp developers (API Demos and Dev Tools). Using these we canlearn about the Android API features such as auto-completion.

Stephen Gilmore Software Engineering Large Practical

Page 26: SELP: Debugging, AVDs and Manifests

Useful functions

shot 2011-09-29 at 13.11.56.png

Stephen Gilmore Software Engineering Large Practical

Page 27: SELP: Debugging, AVDs and Manifests

API demos

shot 2011-09-29 at 13.05.43.png

Stephen Gilmore Software Engineering Large Practical

Page 28: SELP: Debugging, AVDs and Manifests

API demos

shot 2011-09-29 at 13.06.09.png

Stephen Gilmore Software Engineering Large Practical

Page 29: SELP: Debugging, AVDs and Manifests

API demos

shot 2011-09-29 at 13.06.17.png

Stephen Gilmore Software Engineering Large Practical

Page 30: SELP: Debugging, AVDs and Manifests

Auto-complete contacts

shot 2011-09-29 at 13.09.29.png

Stephen Gilmore Software Engineering Large Practical

Page 31: SELP: Debugging, AVDs and Manifests

Manifest filesEvery Android application must have an AndroidManifest.xml

file (with precisely that name) in its root directory. The manifestpresents essential information about the application to the Androidsystem, including information about intents which are messagessent to activities, services and broadcast receivers. The manifestalso specifies permissions which the application requests (such asthe permission to connect to paired Bluetooth devices) andlibraries that it needs.

Stephen Gilmore Software Engineering Large Practical

Page 32: SELP: Debugging, AVDs and Manifests

Manifest files

shot 2011-10-20 at 13.49.36.png

Stephen Gilmore Software Engineering Large Practical

Page 33: SELP: Debugging, AVDs and Manifests

The manifest editor

shot 2011-10-20 at 13.49.57.png

Stephen Gilmore Software Engineering Large Practical

Page 34: SELP: Debugging, AVDs and Manifests

Adding extras

shot 2011-10-20 at 13.50.09.png

Stephen Gilmore Software Engineering Large Practical

Page 35: SELP: Debugging, AVDs and Manifests

Labels and icons

shot 2011-10-20 at 13.50.36.png

Stephen Gilmore Software Engineering Large Practical

Page 36: SELP: Debugging, AVDs and Manifests

Application nodes and intents

shot 2011-10-20 at 13.50.50.png

Stephen Gilmore Software Engineering Large Practical

Page 37: SELP: Debugging, AVDs and Manifests

Attributes for an action

shot 2011-10-20 at 13.51.01.png

Stephen Gilmore Software Engineering Large Practical

Page 38: SELP: Debugging, AVDs and Manifests

Add permissions

shot 2011-10-20 at 13.51.22.png

Stephen Gilmore Software Engineering Large Practical

Page 39: SELP: Debugging, AVDs and Manifests

Add instrumentation

shot 2011-10-20 at 13.51.38.png

Stephen Gilmore Software Engineering Large Practical

Page 40: SELP: Debugging, AVDs and Manifests

Source code view

shot 2011-10-20 at 13.51.48.png

Stephen Gilmore Software Engineering Large Practical

Page 41: SELP: Debugging, AVDs and Manifests

Source code tab

shot 2011-10-20 at 13.51.48.2.png

Stephen Gilmore Software Engineering Large Practical

Page 42: SELP: Debugging, AVDs and Manifests

Resources and strings

An Android application may need resources such as image files andstrings. A string resource provides text strings for the applicationwith optional text styling and formatting.

Stephen Gilmore Software Engineering Large Practical

Page 43: SELP: Debugging, AVDs and Manifests

Resources and strings

shot 2011-10-20 at 14.04.41.png

Stephen Gilmore Software Engineering Large Practical

Page 44: SELP: Debugging, AVDs and Manifests

A String resource, app name

shot 2011-10-20 at 14.04.46.png

Stephen Gilmore Software Engineering Large Practical

Page 45: SELP: Debugging, AVDs and Manifests

Managing string resources

shot 2011-10-20 at 14.05.21.png

Stephen Gilmore Software Engineering Large Practical

Page 46: SELP: Debugging, AVDs and Manifests

Drawable resources

shot 2011-10-20 at 14.05.39.png

Stephen Gilmore Software Engineering Large Practical

Page 47: SELP: Debugging, AVDs and Manifests

Managing drawable resources

shot 2011-10-20 at 14.05.40.png

Stephen Gilmore Software Engineering Large Practical

Page 48: SELP: Debugging, AVDs and Manifests

Contents of app notes.png

shot 2011-10-20 at 14.06.46.png

Stephen Gilmore Software Engineering Large Practical

Page 49: SELP: Debugging, AVDs and Manifests

The icon in the launcher view

shot 2011-10-20 at 18.55.20.png

Stephen Gilmore Software Engineering Large Practical

Page 50: SELP: Debugging, AVDs and Manifests

Editing string resources

String resources can be edited using the Android Resources editor.

Stephen Gilmore Software Engineering Large Practical

Page 51: SELP: Debugging, AVDs and Manifests

Application nodes

shot 2011-10-20 at 14.26.17.png

Stephen Gilmore Software Engineering Large Practical

Page 52: SELP: Debugging, AVDs and Manifests

Browsing

shot 2011-10-20 at 14.26.10.png

Stephen Gilmore Software Engineering Large Practical

Page 53: SELP: Debugging, AVDs and Manifests

Editing strings

shot 2011-10-20 at 14.27.43.png

Stephen Gilmore Software Engineering Large Practical

Page 54: SELP: Debugging, AVDs and Manifests

Updating a string

shot 2011-10-20 at 14.27.49.png

Stephen Gilmore Software Engineering Large Practical

Page 55: SELP: Debugging, AVDs and Manifests

Text in the XML view

shot 2011-10-20 at 14.29.49.png

Stephen Gilmore Software Engineering Large Practical

Page 56: SELP: Debugging, AVDs and Manifests

Updating a string in the Resources view

shot 2011-10-20 at 19.17.37.png

Stephen Gilmore Software Engineering Large Practical

Page 57: SELP: Debugging, AVDs and Manifests

The XML text is updated automatically

shot 2011-10-20 at 19.17.43.png

Stephen Gilmore Software Engineering Large Practical

Page 58: SELP: Debugging, AVDs and Manifests

Getting it wrong: editing the XML

shot 2011-10-20 at 19.27.08.png

Stephen Gilmore Software Engineering Large Practical

Page 59: SELP: Debugging, AVDs and Manifests

The bug shows up in the resources view

shot 2011-10-20 at 19.27.19.png

Stephen Gilmore Software Engineering Large Practical

Page 60: SELP: Debugging, AVDs and Manifests

Oh dear

shot 2011-10-20 at 19.27.23.png

Stephen Gilmore Software Engineering Large Practical

Page 61: SELP: Debugging, AVDs and Manifests

Android Eclipse issues

Working with hand-crafted and automatically-generated Java filescan be confusing. In particular we focus on errors involving theautomatically-generated R.java file.

Stephen Gilmore Software Engineering Large Practical

Page 62: SELP: Debugging, AVDs and Manifests

Oh no, Java problems . . .

shot 2011-10-20 at 14.32.16.png

Stephen Gilmore Software Engineering Large Practical

Page 63: SELP: Debugging, AVDs and Manifests

“Layout cannot be resolved . . . ”

shot 2011-10-20 at 14.32.16.png

Stephen Gilmore Software Engineering Large Practical

Page 64: SELP: Debugging, AVDs and Manifests

R.java is generated so clean the project?

shot 2011-10-20 at 14.32.43.png

Stephen Gilmore Software Engineering Large Practical

Page 65: SELP: Debugging, AVDs and Manifests

No good. Delete R.java and try again?

shot 2011-10-20 at 14.33.17.png

Stephen Gilmore Software Engineering Large Practical

Page 66: SELP: Debugging, AVDs and Manifests

R.java is regenerated but errors remain

shot 2011-10-20 at 14.33.27.png

Stephen Gilmore Software Engineering Large Practical

Page 67: SELP: Debugging, AVDs and Manifests

Refresh the view?

shot 2011-10-20 at 14.34.38.png

Stephen Gilmore Software Engineering Large Practical

Page 68: SELP: Debugging, AVDs and Manifests

No good. What now?

shot 2011-10-20 at 14.37.33.png

Stephen Gilmore Software Engineering Large Practical

Page 69: SELP: Debugging, AVDs and Manifests

Close the project and reopen it?

shot 2011-10-20 at 14.43.57.png

Stephen Gilmore Software Engineering Large Practical

Page 70: SELP: Debugging, AVDs and Manifests

Reopening the project. Praying . . .

shot 2011-10-20 at 14.44.05.png

Stephen Gilmore Software Engineering Large Practical

Page 71: SELP: Debugging, AVDs and Manifests

Didn’t work :-( but look at this . . .

shot 2011-10-20 at 15.12.05.png

Stephen Gilmore Software Engineering Large Practical

Page 72: SELP: Debugging, AVDs and Manifests

Moving the folder fixes the problem :-)

shot 2011-10-20 at 15.11.43.png

Stephen Gilmore Software Engineering Large Practical

Page 73: SELP: Debugging, AVDs and Manifests

Moving the folder fixes the problem :-)

shot 2011-10-20 at 15.12.29.png

Stephen Gilmore Software Engineering Large Practical