Information Technology Reference
In-Depth Information
formatting the output as explained in [17]. The Android eclipse plugin provides
a more convenient graphical user interface to logcat.
A log entry can be produced by invoking the static methods in the android.
util.Log class. For instance, the statement Log.e("TAG", "Ooops") creates an
error line in the log. The Log.e method takes two parameters: The tag (first pa-
rameter) can be used for filtering and categorization. The error message (second
parameter) contains the error message or failure reason.
Android Emulator. As the name already suggests, the Android emulator [18]
is a virtual mobile device that runs on a computer and is similar to a real device.
It does not contain all the features of a real mobile device such as sending emails,
but for most purposes, it is suciently complete. However, note that applications
may suffer from serious performance penalties when run on the emulator.
With the help of the Android debug bridge [19], it is easy to create a new emu-
lator. The command android create avd -n <name> -t <targetID> creates
a new virtual device with the given name. The targetID is the API level one
needs, e.g., 17 for Android 4.2. The new emulator is started by emulator -avd
<name> . Afterwards, the virtual device's user interface is shown and one can
interact with the emulator through the SDK's command-line tools. A more con-
venient way for the creation of an emulator is the usage of the grafical interface
provided by eclipse ( Android Virtual Device Manager ).
2.6 Managing APKs on the Device
For author identification purposes, the Android framework requries that each
application has to be signed with a certificate. This, for instance, allows the
system to check whether an application update actually comes from the original
application developer. Furthermore, applications signed with the same key are
granted special privileges in interprocess communication. On the Android plat-
form, it is common that most of the application certificates are self-signed [20].
When changing the APK file, e.g., by instrumenting the code, the signature is
lost and the application must be signed again.
Standard tools like keytool and jarsigner can be used for signing the applica-
tion. An example for the generation of a private/public key pair with keytool [20]
is shown in Listing 1.2.
1 $ keytool -genkey -v -keystore my-release-key.keystore
2 -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Listing 1.2. Generation of a private/public key pair with keytool [20]
The jarsigner tool can be used for signing the application my application.apk
with the private key generated with keytool. Listing 1.3 shows the command for
signing an app with jarsigner.
1 $ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore
2 my-release-key.keystore my_application.apk alias_name
Listing 1.3. Signing my application.apk with jarsinger [20]
 
Search WWH ::




Custom Search