Android Security Cookbook
Android Security
Cookbook
Android DevelopmentTools
In this chapter, we will cover the following recipes:
ff Installing the Android Development Tools (ADT)
ff Installing the Java Development Kit (JDK)
ff Updating the API sources
ff Alternative installation of the ADT
ff Installing the Native Development Kit (NDK)
ff Emulating Android
ff Creating Android Virtual Devices (AVDs)
ff Using the Android Debug Bridge (ADB) to interact with the AVDs
ff Copying files off/onto an AVD
ff Installing applications on the AVDs via ADB
Introduction
A very clever person once said that, "you should keep your friends close but your enemies
closer". Being a security professional means keeping an eye on what developers are doing,
have done, and are likely to do. This is because the decisions they make greatly affect the
security landscape; after all, if no one wrote bad software, no one would exploit it!
Android Development Tools
8
Given that this book is aimed at anyone interested in analyzing, hacking, or developing the
Android platform, the know thy enemy concept applies to you too! Android developers need to
stay somewhat up to date with what Android hackers are up to if they hope to catch security
vulnerabilities before they negatively affect the users. Conversely, Android hackers need to
stay up to date with what Android developers are doing.
The upcoming chapters will walk you through getting the latest and greatest development and
hacking tools and will get you to interact directly with the Android security architecture, both
by breaking applications and securing them.
This chapter focuses on getting the Android Development Tools (ADT) up and running and
discusses how to troubleshoot an installation and keep them up to date. If you feel you are
already well-acquainted with the Android development environment and tool chains, feel free
to skip this chapter.
Without further ado, let's talk about grabbing and installing the latest Android
Development Tools.
Installing the Android Development Tools
(ADT)
Given that there are many versions of the Android framework already deployed on mobile
platforms and a variety of handsets that support it, Android developers need tools that
give them access to many device- and operating system-specific Application Programming
Interfaces (APIs) available on the Android platform.
We're talking about not just the Android APIs but also handset-specific APIs. Each handset
manufacturer likes to invest in the developer mindshare in their own way by providing
exclusive APIs and services to their developers, for example, the HTC OpenSense APIs. The
ADT consolidates access to these APIs; provides all the necessary tools to debug, develop,
and deploy your Android apps; and makes it easy for you to download them and keep them
up to date.
How to do it...
The following steps will walk you through the process of downloading the ADT and getting
them up and running:
1. You'll need to head over to https://developer.android.com and navigate
to the ADT Download page or just visit https://developer.android.com/
sdk/index.html#download. You should see a page like the one in the following
screenshot:
Chapter 1
9
2. Once you're there, click on Download the SDK and the following screen
should appear:
Android Development Tools
10
3. Of course, you will need to accept the license agreement before downloading and
select the appropriate CPU type, or register size if you're not sure how to check your
CPU type.
On Windows, you need to complete the following steps:
1. Click on Start.
2. Right-click on My Computer.
3. Select Properties.
4. A window with your computer's system-specific information should pop up.
The information you are looking for should be under the System section,
labeled System type.
To check your system type on Ubuntu, Debian, or Unix-based distributions, perform
the following steps:
1. Open a terminal either by pressing Ctrl + Alt + T or simply launching it using
the graphical interface.
2. Execute the following command:
uname -a
Chapter 1
11
3. Alternatively, you could use lscpu that should show you something like the
following screenshot:
4. When you're happy with the license agreement and you've selected the correct
system type, click on Download in the ADT Download page. Once the ZIP file has
been downloaded, it should look like the following screenshot on Windows:
The archive will have the same structure on the Linux- or Unix-based distributions.
Android Development Tools
12
Installing the Java Development Kit (JDK)
Android uses a customized version of the Java runtime to support its applications. This
means, before we can get going with Eclipse and developing Android applications, we actually
need to install the Java runtime and development tools. These are available in the Java
Development Kit (JDK).
How to do it...
Installing the JDK on Windows works as follows:
1. Grab a copy of the JDK from Oracle's Downloads page, http://www.oracle.com/
technetwork/java/javase/downloads/index.html. Click on DOWNLOAD.
The following screenshot shows the Downloads page:
Chapter 1
13
2. Make sure to select the appropriate version for your system type; see the previous
walkthrough to find out how to check your system type. The following screenshot
highlights the Windows system types supported by the Oracle Java JDK:
3. After downloading the JDK, run the jdk-[version]-[platform version].
exe file. For instance, you could have an EXE file named something like jdk-
7u21-windows-i586.exe. All you need to do now is follow the prompts until the
installation of all the setups is completed. The following screenshot is what the install
wizard should look like once it's launched:
Android Development Tools
14
Once the install wizard has done its job, you should see a fresh install of your JDK and JRE under
C:\Program Files\Java\jdk[version] and should now be able to launch Eclipse.
There's more…
Installing the Java Runtime and Development tools on Ubuntu Linux is somewhat simpler.
Seeing that Ubuntu has a sophisticated package and repository manager, all you need to do
is make use of it by firing off a few simple commands from the terminal window. You need to
execute the following steps:
1. Open a terminal, either by searching for the terminal application via your Unity, KDE,
or Gnome desktop or by pressing Ctrl + Alt + T.
2. You may need to update your package list before installation, unless you've already
done that a couple of minutes ago. You can do this by executing either of the
following commands:
sudo aptitude update //If you have aptitude installed
Or:
sudo apt-get update
You should see your terminal print out all the downloads it's performing from your
repositories as shown in the following screenshot:
Chapter 1
15
3. Once that's done, execute the following command:
sudo apt-get install openjdk-[version]-jdk apt-get
You will need to enter your password if you have been added to your sudoers file
correctly. Alternatively, you could borrow root privileges to do this by executing the
following command, assuming that you have the root user's password:
su root
This is displayed in the following screenshot:
Once your JDK is installed properly, you should be able to launch Eclipse and get going with
your Android development. When you launch Eclipse, you should see the following screenshot:
After successful installation, the toolbar in your Eclipse installation should look something like
the one in the following screenshot:
download
No comments:
Post a Comment