Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Android 6: Testing and Running the App Kirk Scott 1."— Presentation transcript:

1 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 2

3 6.1 Introduction 3

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 4

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 5

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 6

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 7

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… 8

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 9

10 6.2 The Emulator, Creating a Virtual Device 10

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 11

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 12

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 13

14 14

15 Click the New button to create an Android Virtual Device The window shown in the screenshot on the following overhead comes up 15

16 16

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

18 18

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 19

20 20

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 21

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 22

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 23

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 24

25 25

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 26

27 6.3 Running an App on a Virtual Device 27

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 28

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 29

30 30

31 If you click the Start button the following screen should appear This is the magic moment Click Launch 31

32 32

33 After clicking launch, you should see the screen with the progress bar shown on the following overhead So far so good 33

34 34

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 35

36 36

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 37

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 38

39 39

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 40

41 41

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 42

43 43

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 44

45 45

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 46

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 47

48 48

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) 49

50 50

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

52 52

53 6.4 Drivers 53

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 54

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 55

56 56

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 57

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 58

59 6.5 Getting the Device Ready 59

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 60

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 61

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 62

63 Take Developer options Under Debugging, enable USB debugging You can now connect the device to your system using a USB cable 63

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) 64

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 65

66 66

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 67

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 68

69 6.7 Summary 69

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 70

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 71

72 The End 72


Download ppt "Android 6: Testing and Running the App Kirk Scott 1."

Similar presentations


Ads by Google