Installing Kilo Gap in the Emulator

Now it's time to test our shiny new native Android app in the emulator.

1. If your emulator is not running, launch it by entering the following command in the Terminal application (this way, you can let it "warm up" while you're building the Kilo package):

emulator -avd mySim

You should see the Android emulator window appear after a few seconds. Notice that the command prompt doesn't return in the terminal window—it will sort of just sit there and hang until you close the emulator. We won't be interacting with this window, so you can minimize it to get it out of the way.

2. Open a new terminal window and navigate into the KiloGap directory. In my case, the command to do so is:

cd ~/Desktop/KiloGap

3. Enter the following command to compile your app with debugging enabled:

ant debug

If all goes well, you'll see a stream of output with BUILD SUCCESSFUL at the end (Figure 7-10). A binary executable named Kilo-debug.apk will now be sitting in the ~/Desktop/KiloGap/bin directory (Figure 7-11). If the build is not successful, repeat the steps in "Build KiloGap" on page 118.

[setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (2) is lower than the project target API level (8) [setup] Importing rules file: platforms/android-8/ant/ant_rules_r2,xml

-compile-tested-if-test:

-di rsi

[echo] Creating output directories if needed,,.

[echo] Generating R.java / Manifest,java from the resources,,.

[null] (skipping hidden file '/Users/jstark/Desktop/KiloGap/res/.DS_Store')

-aidli

[echo] Compiling aidl files into Java classes,..

compile:

[javac] Compiling 1 source file to /Users/jstark/Desktop/KiloGap/bin/classes

[echo] Converting compiled files and external libraries into /Users/jstark/Desktop/KiloGap/bin/classes,dex...

-package-resources:

[echo] Fackaging resources [aaptexec] Creating full resource package,..

[null] (skipping hidden file 1/Users/jstark/Desktop/KiloGap/assets/.DS_Store') [null] (skipping hidden file '/Users/jstark/Desktop/KiloGap/assets/www/,DS_Store') [null] (skipping hidden file 1 / Use rs/ j sta rk/Desk top/ Ki loGap/ res/ . DS_Sto re 1)

-package-debug-si gn:

[apkbuilder] Creating Kilo-debug-unaligned,apk and signing it with a debug key,,, [apkbuilder] Using keystore: /Users/jstark/.android/debug.keystore

BUILD SUCCESSFUL Total time; 4 seconds J5C-HBP:KiloGap jstarki

Figure 7-10. If the ant debug command finishes without errors, you'll see BUILD SUCCESSFUL at the end of the output

Lj KiloCap

16 ¡ten

is, 129.06 CG available

? AndroidManifest.xml

Today, 3:32 PM

Today, 3:3

► Cj assets

Today, 3:32 PM

Today, 3:3

▼ m bin

Today, 3:33 PM

Today, 3:3

► classes

Today, 3:33 PM

Today, 3:1

classes.dex

Today, 3:33 PM

Today, 3:3

Kilo-debug-unaligned,apk

Today, 3:33 PM

Today, 3:3

Kilo-debug.apk

Today, 3:33 PM

Today, 3:3

KIIo.ap_

Today, 3:33 PM

Today, 3:3

e build,properties

Today, 3:32 PM

Today, 3:3

e build.xml

Today, 3:32 PM

Today, 3:3

default.properties

Today, 3:32 PM

Today, 3:3

► gen

Today, 3:33 PM

Today, 3:3.

► Q libs

Today, 3:32 PM

Today, 3:3

2 local.properties

Today, 3:32 PM

Today, 3:3

► LJ res

Today, 3:32 PM

Today, 3:3

► LJ src

Today, 3:32 PM

Today, 3:3

Figure 7-11. The ant debug command will create the Kilo-debug.apk binary in the KiloGap's bin directory

4. Now that we have a binary, we can install it on the emulator. To do so, enter the following command (if you're using a different location, replace ~/Desktop/Kilo-Gap/bin/ with the location of the bin subdirectory of wherever you told droidgap to create the project back in step 5 on page 120):

adb -e install -r ~/Desktop/KiloGap/bin/Kilo-debug.apk

"adb" is short for Android Debug Bridge, which is a tool that is included in the Android SDK we installed earlier in the chapter. The -e flag tells adb to install our binary package (i.e., ~/Desktop/KiloGap/bin/Kilo-debug.apk) on the first running emulator that it finds. The -r flag tells adb to replace the binary on the emulator if it has been installed previously. If you get a "device offline" error, go into the emulator and unlock it if it's locked (for example, on Android 2.2, slide the green lock icon to the right), then try again.

Your app is now available on the emulator just like any other application (Figure 7-12). To play around with it, locate Kilo in the application launcher and tap it to launch the app. You'll notice right away that there is a bit of cleanup to do. For example, there is an approximately 40px gap at the bottom of the window (Figure 7-13).

Figure 7-12. Your app is now available on the emulator, just like any other application
Figure 7-13. Your web app is now running as a native app on the Android Emulator
0 0

Responses

  • Kathrin
    How to Installing KiloGap in the Emulator for android?
    8 years ago

Post a comment