72
Android 6: Testing and Running the App Kirk Scott 1

Android 6: Testing and Running the App Kirk Scott 1

Embed Size (px)

Citation preview

Page 1: Android 6: Testing and Running the App Kirk Scott 1

1

Android 6: Testing and Running the App

Kirk Scott

Page 2: Android 6: Testing and Running the App Kirk Scott 1

2

Outline

• 6.1 Introduction• 6.2 The Emulator, Creating a Virtual Device• 6.3 Running an App on a Virtual Device• 6.4 Drivers• 6.5 Getting the Device Ready• 6.6 Uploading and Running on a Real Device• 6.7 Summary

Page 3: Android 6: Testing and Running the App Kirk Scott 1

3

6.1 Introduction

Page 4: Android 6: Testing and Running the App Kirk Scott 1

4

• Troubles, troubles, troubles• This set of overheads has the same

fundamental problem as the previous set• It’s possible to lay out a step-by-step guide,

but technical problems can arise• Because the approach is for users, not

developers, the technical problems can be incomprehensible and insoluble

Page 5: Android 6: Testing and Running the App Kirk Scott 1

5

• The two topics of this set of overheads are:• Testing and running an app on the emulator in

Eclipse• Uploading and running an app on an Android

device

Page 6: Android 6: Testing and Running the App Kirk Scott 1

6

• The emulator is slow, and depending on how it’s set up, it might not work

• It’s always possible to make a new emulator and try again, but it’s frustrating

Page 7: Android 6: Testing and Running the App Kirk Scott 1

7

• Uploading is supposed to be straightforward, except when it’s not…

• The following thumbnail will describe just how bad this can be:

• I can upload and run from my laptop

Page 8: Android 6: Testing and Running the App Kirk Scott 1

8

• I also have a newer, more powerful desktop machine in my office

• Unfortunately, Microsoft overrides the driver installations on that machine, and it has never been possible for me to upload to an attached device…

Page 9: Android 6: Testing and Running the App Kirk Scott 1

9

Eclipse Components Relevant to this Set of Overheads

• As before, the starting point for the following overheads is a successful installation of Java and the ADT bundle on your system

• There is an Android Virtual Device Manager tool

• There is an Android SDK Manager tool• These pieces of software will come up in the

discussions which follow

Page 10: Android 6: Testing and Running the App Kirk Scott 1

10

6.2 The Emulator, Creating a Virtual Device

Page 11: Android 6: Testing and Running the App Kirk Scott 1

11

The Android Virtual Device Manager

• The Android Virtual Device Manager tool allows you to set up virtual devices to test your software on

• In the Eclipse toolbar It’s located next to the Android SDK Manager tool

• This is the icon, more or less

Page 12: Android 6: Testing and Running the App Kirk Scott 1

12

• The icon in the toolbar is so small that you might have trouble recognizing it

• You can also access the tool by going to the Window Menu

• There you will find an option for the virtual device manager

Page 13: Android 6: Testing and Running the App Kirk Scott 1

13

• If you want to run the project using the emulator, you need to use the Android Virtual Device Manager to create a new virtual device

• If you take the Android Virtual Device Manager tool (or menu option) you should arrive at something similar to the screenshot shown on the following overhead

Page 14: Android 6: Testing and Running the App Kirk Scott 1

14

Page 15: Android 6: Testing and Running the App Kirk Scott 1

15

• Click the New button to create an Android Virtual Device

• The window shown in the screenshot on the following overhead comes up

Page 16: Android 6: Testing and Running the App Kirk Scott 1

16

Page 17: Android 6: Testing and Running the App Kirk Scott 1

17

• It’s shown on the following overhead with the drop down list for Device expanded

Page 18: Android 6: Testing and Running the App Kirk Scott 1

18

Page 19: Android 6: Testing and Running the App Kirk Scott 1

19

• I tried using various devices• For initial test purposes I finally settled on the

device at the bottom of the list• My theory was that emulation for older,

simpler devices might work better or faster than for newer devices

• On the following overhead the form is shown filled out with representative values for that simple device

Page 20: Android 6: Testing and Running the App Kirk Scott 1

20

Page 21: Android 6: Testing and Running the App Kirk Scott 1

21

Using Snapshot

• Another mystery:• Certain reference sources waffle on the

desirability of the Snapshot option• If you do select Snapshot and then make other

changes, you may have troubles later• Without Snapshot things might run more

slowly, but again, for the first time, try it without Snapshot

Page 22: Android 6: Testing and Running the App Kirk Scott 1

22

Warning

• Here is an example of what can go wrong• I also tried making a virtual device that was a

Nexus tablet (the real hardware I’m working with)

• The memory option defaulted to a RAM value of 1024

• Unfortunately, when I continued with that value of 1024, I got a mystery error

Page 23: Android 6: Testing and Running the App Kirk Scott 1

23

• My Web search informed me that if I changed the RAM value to 512, things should be OK

• For the device I’ve chosen to illustrate with, I took memory size values of 256

• For whatever reason, these values worked, and for the time being, that’s good enough for me

Page 24: Android 6: Testing and Running the App Kirk Scott 1

24

Continuing with Virtual Device Creation

• Once you’ve got the parameters set, click on OK

• The system can drag on for a noticeable amount of time creating the virtual device

• Successful completion is indicated by the appearance of the device in the list as shown in the screenshot on the following overhead

Page 25: Android 6: Testing and Running the App Kirk Scott 1

25

Page 26: Android 6: Testing and Running the App Kirk Scott 1

26

• There is no final OK step after virtual device creation

• You’re done—and you have to close this window

• If you just minimize it, it sits there but is still the active window

• To go on from here, close this window

Page 27: Android 6: Testing and Running the App Kirk Scott 1

27

6.3 Running an App on a Virtual Device

Page 28: Android 6: Testing and Running the App Kirk Scott 1

28

• Starting the emulator can take a lot of time• Trying to run the app and having that process

start the emulator doesn’t work well• The alternative is to start the emulator and

then run the app in it• This second approach is a better way to do it

Page 29: Android 6: Testing and Running the App Kirk Scott 1

29

Starting the Emulator

• The Android Virtual Device screen is shown again on the following overhead with the created virtual device in it

• The screenshot shows the device as being selected and you’ll note a Start… button on the right hand side

Page 30: Android 6: Testing and Running the App Kirk Scott 1

30

Page 31: Android 6: Testing and Running the App Kirk Scott 1

31

• If you click the Start button the following screen should appear

• This is the magic moment• Click Launch

Page 32: Android 6: Testing and Running the App Kirk Scott 1

32

Page 33: Android 6: Testing and Running the App Kirk Scott 1

33

• After clicking launch, you should see the screen with the progress bar shown on the following overhead

• So far so good

Page 34: Android 6: Testing and Running the App Kirk Scott 1

34

Page 35: Android 6: Testing and Running the App Kirk Scott 1

35

• Even before the previous screen goes away, or at the very least, as soon as it finishes, you should see the emulator on the screen

• It’s conceivable that you’ll have to close some things to find it

• It may be hidden• In any case, the initial stage of launch shouldn’t

take a long time, and this is what you should see

Page 36: Android 6: Testing and Running the App Kirk Scott 1

36

Page 37: Android 6: Testing and Running the App Kirk Scott 1

37

Even If Things are Going OK, This is the Painful Part

• What you need now is patience (potentially a lot of it) and faith

• The Android message on the emulated device will flash white for an indeterminate period of time

• The emulator is still launching• As long as that process is going on, there’s

nothing else that you should do• You just have to wait

Page 38: Android 6: Testing and Running the App Kirk Scott 1

38

Edging Towards Success

• Eventually, with good luck, the emulator will look as shown on the following overhead

• In the screenshot that is shown, the emulator screen is grayed out

Page 39: Android 6: Testing and Running the App Kirk Scott 1

39

Page 40: Android 6: Testing and Running the App Kirk Scott 1

40

• If your emulator is grayed out, click and drag over the emulator screen with the mouse

• This should wake it up, as shown on the following overhead

Page 41: Android 6: Testing and Running the App Kirk Scott 1

41

Page 42: Android 6: Testing and Running the App Kirk Scott 1

42

• Click on the circle as directed• If the apps are shown, as they are in the

following screenshot, you have been successful

• The emulator has been launched and is running

Page 43: Android 6: Testing and Running the App Kirk Scott 1

43

Page 44: Android 6: Testing and Running the App Kirk Scott 1

44

Running the Project in the Emulator

• If you want to run the project configurations, you need a source file for the project open in the Eclipse environment

• The screenshot on the following overhead shows the explorer on the left tracing the path to the MyFirstApp.java file, with that file open in the editor in the middle

Page 45: Android 6: Testing and Running the App Kirk Scott 1

45

Page 46: Android 6: Testing and Running the App Kirk Scott 1

46

• If you followed the directions in the previous sets of overheads, the project would be ready to run

• If you want to or if necessary, you can “Clean” it again in preparation for running

• After a “cleaning” with no problems, to run the app, go to the Run menu in the menu bar and take the Run option in it

Page 47: Android 6: Testing and Running the App Kirk Scott 1

47

• The first time you to try to run a project, you may get another dialog box asking what kind of thing you’re trying to run

• You’re given a list of choices, and the choice you want to make is “Android application”

• This dialog is shown on the following overhead

Page 48: Android 6: Testing and Running the App Kirk Scott 1

48

Page 49: Android 6: Testing and Running the App Kirk Scott 1

49

• After choosing the right run type, once again there may be a certain amount of waiting

• Switch back to the emulator• It should eventually something like the screen

shot on the following overhead• (This an app which simply happens not to be

the flashcard app)

Page 50: Android 6: Testing and Running the App Kirk Scott 1

50

Page 51: Android 6: Testing and Running the App Kirk Scott 1

51

• Click and drag over the emulator screen, and it comes to life, as shown on the following overhead

Page 52: Android 6: Testing and Running the App Kirk Scott 1

52

Page 53: Android 6: Testing and Running the App Kirk Scott 1

53

6.4 Drivers

Page 54: Android 6: Testing and Running the App Kirk Scott 1

54

The Android SDK Manager• The Android SDK Manager tool allows you to

keep the SDK installation up to date• The icon is the top half of the Android shown

here with a down arrow in place of the bottom half

Page 55: Android 6: Testing and Running the App Kirk Scott 1

55

• You can also find it by going to the Window menu in Eclipse

• A screenshot of the Android SDK Manager tool is shown on the following overhead

Page 56: Android 6: Testing and Running the App Kirk Scott 1

56

Page 57: Android 6: Testing and Running the App Kirk Scott 1

57

• For a developer, this tool makes it possible manage the installation of all tools in Eclipse

• The third line from the bottom shows that the Google USB driver is installed

• This is necessary for running on an attached device

• It should happen automatically

Page 58: Android 6: Testing and Running the App Kirk Scott 1

58

• If it didn’t happen automatically, you can use the tool to retrieve and install the driver

• As noted at the beginning of these overheads, occasionally Microsoft Windows will be in conflict with this and will override the desired driver with one of its own

• If this happen, the following steps for running the app on a device won’t work

Page 59: Android 6: Testing and Running the App Kirk Scott 1

59

6.5 Getting the Device Ready

Page 60: Android 6: Testing and Running the App Kirk Scott 1

60

• You need to have the USB driver installed, because your device will be connected to your development machine with a USB cable

• After the driver is installed you have to get the device ready

• The device has to be in developer mode so that you it’s possible to transfer the app to the device

Page 61: Android 6: Testing and Running the App Kirk Scott 1

61

• For reference purposes, these overheads were prepared with the following:

• Windows 7 on the development machine• Eclipse, as already described• A Nexus 7 tablet• The fact that it was the Nexus 7 tablet is

relevant to the specific instructions for getting the device ready

Page 62: Android 6: Testing and Running the App Kirk Scott 1

62

• On the running device, go to the App screen• Tap on Settings• Under System, find About tablet• Tap Build number 7 times• When you return from doing this you should

find Developer options under System

Page 63: Android 6: Testing and Running the App Kirk Scott 1

63

• Take Developer options• Under Debugging, enable USB debugging• You can now connect the device to your

system using a USB cable

Page 64: Android 6: Testing and Running the App Kirk Scott 1

64

6.6 Uploading and Running on a Real Device

• The assumption is that you successfully installed the driver and your device is attached with a USB cable

• Open one of the .java files of your app in Eclipse

• (If necessary, clean it)

Page 65: Android 6: Testing and Running the App Kirk Scott 1

65

• Take the Run option in the menu• This should cause the Android Device Chooser

to appear on the screen, with the Nexus 7 device in the list

• This is shown on the following overhead

Page 66: Android 6: Testing and Running the App Kirk Scott 1

66

Page 67: Android 6: Testing and Running the App Kirk Scott 1

67

• Select your device and click OK• The magic should happen• The app should run on your device• In addition to running, it will effectively be

installed on the device

Page 68: Android 6: Testing and Running the App Kirk Scott 1

68

• In other words, you can now disconnect the USB cable

• If you go to the apps screen you’ll still find the little green Android icon for your app and you can run it from on the device in the future

• If you make changes on the development machine, you can go through the same steps to reload the changed app onto the device again

Page 69: Android 6: Testing and Running the App Kirk Scott 1

69

6.7 Summary

Page 70: Android 6: Testing and Running the App Kirk Scott 1

70

• This set of overheads covered the following topics

• Using the Android emulator in Eclipse, creating virtual device

• Running an app on the virtual device on the development machine

Page 71: Android 6: Testing and Running the App Kirk Scott 1

71

• The need for the Google USB driver in order to connect a real device to the development machine

• Putting the device into developer mode so that it’s able to receive an uploaded app

• Running an app on attached real device

Page 72: Android 6: Testing and Running the App Kirk Scott 1

72

The End