SELP: Debugging, AVDs and Manifests

Preview:

DESCRIPTION

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

Citation preview

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

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

DDMS perspective in Eclipse

shot 2011-09-29 at 12.05.14.png

Stephen Gilmore Software Engineering Large Practical

Set your location

shot 2011-09-29 at 12.03.05.png

Stephen Gilmore Software Engineering Large Practical

LogCat — a log of events on the phone

shot 2011-09-29 at 12.06.56.png

Stephen Gilmore Software Engineering Large Practical

File Explorer — see files on the phone

shot 2011-09-29 at 12.07.32.png

Stephen Gilmore Software Engineering Large Practical

Devices — see processes in the emulator

shot 2011-09-29 at 12.10.14.png

Stephen Gilmore Software Engineering Large Practical

Allocation tracker

shot 2011-09-29 at 12.10.28.png

Stephen Gilmore Software Engineering Large Practical

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

Creating an emulator

shot 2011-09-29 at 12.13.31.png

Stephen Gilmore Software Engineering Large Practical

Android Virtual Device (AVD) manager

shot 2011-09-29 at 12.13.40.png

Stephen Gilmore Software Engineering Large Practical

Create a new AVD (Click New...)

shot 2011-09-29 at 12.14.01.png

Stephen Gilmore Software Engineering Large Practical

Create new Android Virtual Device

shot 2011-09-29 at 12.21.54.png

Stephen Gilmore Software Engineering Large Practical

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

Start the new AVD

shot 2011-09-29 at 12.22.07.png

Stephen Gilmore Software Engineering Large Practical

Launch Options

shot 2011-09-29 at 12.22.18.png

Stephen Gilmore Software Engineering Large Practical

Emulator launches ...

shot 2011-09-29 at 12.23.31.png

Stephen Gilmore Software Engineering Large Practical

Emulator home page is displayed

shot 2011-09-29 at 13.03.13.png

Stephen Gilmore Software Engineering Large Practical

Click to display options

shot 2011-09-29 at 13.03.14.png

Stephen Gilmore Software Engineering Large Practical

Functions of the phone

shot 2011-09-29 at 13.03.57.png

Stephen Gilmore Software Engineering Large Practical

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

Useful functions

shot 2011-09-29 at 13.11.56.png

Stephen Gilmore Software Engineering Large Practical

Developer Tools

shot 2011-09-29 at 13.04.23.png

Stephen Gilmore Software Engineering Large Practical

Running processes

shot 2011-09-29 at 13.05.16.png

Stephen Gilmore Software Engineering Large Practical

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

Useful functions

shot 2011-09-29 at 13.11.56.png

Stephen Gilmore Software Engineering Large Practical

API demos

shot 2011-09-29 at 13.05.43.png

Stephen Gilmore Software Engineering Large Practical

API demos

shot 2011-09-29 at 13.06.09.png

Stephen Gilmore Software Engineering Large Practical

API demos

shot 2011-09-29 at 13.06.17.png

Stephen Gilmore Software Engineering Large Practical

Auto-complete contacts

shot 2011-09-29 at 13.09.29.png

Stephen Gilmore Software Engineering Large Practical

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

Manifest files

shot 2011-10-20 at 13.49.36.png

Stephen Gilmore Software Engineering Large Practical

The manifest editor

shot 2011-10-20 at 13.49.57.png

Stephen Gilmore Software Engineering Large Practical

Adding extras

shot 2011-10-20 at 13.50.09.png

Stephen Gilmore Software Engineering Large Practical

Labels and icons

shot 2011-10-20 at 13.50.36.png

Stephen Gilmore Software Engineering Large Practical

Application nodes and intents

shot 2011-10-20 at 13.50.50.png

Stephen Gilmore Software Engineering Large Practical

Attributes for an action

shot 2011-10-20 at 13.51.01.png

Stephen Gilmore Software Engineering Large Practical

Add permissions

shot 2011-10-20 at 13.51.22.png

Stephen Gilmore Software Engineering Large Practical

Add instrumentation

shot 2011-10-20 at 13.51.38.png

Stephen Gilmore Software Engineering Large Practical

Source code view

shot 2011-10-20 at 13.51.48.png

Stephen Gilmore Software Engineering Large Practical

Source code tab

shot 2011-10-20 at 13.51.48.2.png

Stephen Gilmore Software Engineering Large Practical

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

Resources and strings

shot 2011-10-20 at 14.04.41.png

Stephen Gilmore Software Engineering Large Practical

A String resource, app name

shot 2011-10-20 at 14.04.46.png

Stephen Gilmore Software Engineering Large Practical

Managing string resources

shot 2011-10-20 at 14.05.21.png

Stephen Gilmore Software Engineering Large Practical

Drawable resources

shot 2011-10-20 at 14.05.39.png

Stephen Gilmore Software Engineering Large Practical

Managing drawable resources

shot 2011-10-20 at 14.05.40.png

Stephen Gilmore Software Engineering Large Practical

Contents of app notes.png

shot 2011-10-20 at 14.06.46.png

Stephen Gilmore Software Engineering Large Practical

The icon in the launcher view

shot 2011-10-20 at 18.55.20.png

Stephen Gilmore Software Engineering Large Practical

Editing string resources

String resources can be edited using the Android Resources editor.

Stephen Gilmore Software Engineering Large Practical

Application nodes

shot 2011-10-20 at 14.26.17.png

Stephen Gilmore Software Engineering Large Practical

Browsing

shot 2011-10-20 at 14.26.10.png

Stephen Gilmore Software Engineering Large Practical

Editing strings

shot 2011-10-20 at 14.27.43.png

Stephen Gilmore Software Engineering Large Practical

Updating a string

shot 2011-10-20 at 14.27.49.png

Stephen Gilmore Software Engineering Large Practical

Text in the XML view

shot 2011-10-20 at 14.29.49.png

Stephen Gilmore Software Engineering Large Practical

Updating a string in the Resources view

shot 2011-10-20 at 19.17.37.png

Stephen Gilmore Software Engineering Large Practical

The XML text is updated automatically

shot 2011-10-20 at 19.17.43.png

Stephen Gilmore Software Engineering Large Practical

Getting it wrong: editing the XML

shot 2011-10-20 at 19.27.08.png

Stephen Gilmore Software Engineering Large Practical

The bug shows up in the resources view

shot 2011-10-20 at 19.27.19.png

Stephen Gilmore Software Engineering Large Practical

Oh dear

shot 2011-10-20 at 19.27.23.png

Stephen Gilmore Software Engineering Large Practical

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

Oh no, Java problems . . .

shot 2011-10-20 at 14.32.16.png

Stephen Gilmore Software Engineering Large Practical

“Layout cannot be resolved . . . ”

shot 2011-10-20 at 14.32.16.png

Stephen Gilmore Software Engineering Large Practical

R.java is generated so clean the project?

shot 2011-10-20 at 14.32.43.png

Stephen Gilmore Software Engineering Large Practical

No good. Delete R.java and try again?

shot 2011-10-20 at 14.33.17.png

Stephen Gilmore Software Engineering Large Practical

R.java is regenerated but errors remain

shot 2011-10-20 at 14.33.27.png

Stephen Gilmore Software Engineering Large Practical

Refresh the view?

shot 2011-10-20 at 14.34.38.png

Stephen Gilmore Software Engineering Large Practical

No good. What now?

shot 2011-10-20 at 14.37.33.png

Stephen Gilmore Software Engineering Large Practical

Close the project and reopen it?

shot 2011-10-20 at 14.43.57.png

Stephen Gilmore Software Engineering Large Practical

Reopening the project. Praying . . .

shot 2011-10-20 at 14.44.05.png

Stephen Gilmore Software Engineering Large Practical

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

shot 2011-10-20 at 15.12.05.png

Stephen Gilmore Software Engineering Large Practical

Moving the folder fixes the problem :-)

shot 2011-10-20 at 15.11.43.png

Stephen Gilmore Software Engineering Large Practical

Moving the folder fixes the problem :-)

shot 2011-10-20 at 15.12.29.png

Stephen Gilmore Software Engineering Large Practical

Recommended