720 likes | 896 Views
Android 6: Testing and Running the App. Kirk Scott. 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.
E N D
Android 6: Testing and Running the App Kirk Scott
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
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
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
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
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
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…
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
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
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
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
Click the New button to create an Android Virtual Device • The window shown in the screenshot on the following overhead comes up
It’s shown on the following overhead with the drop down list for Device expanded
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
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
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
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
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
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
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
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
If you click the Start button the following screen should appear • This is the magic moment • Click Launch
After clicking launch, you should see the screen with the progress bar shown on the following overhead • So far so good
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
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
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
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
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
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
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
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
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 likethe screen shot on the following overhead • (This an app which simply happens not to be the flashcard app)