From zero to the screenlock

So far we have gathered an incredible amount of information about the architecture, about how to configure the build system, and our PoC device. It's time to create our first image for a real device and use it! We want to keep away all the possible hardware-related issues, so we will target the simplest nonhardware Android device: the Android emulator.

We are going to build the latest available Android Lollipop source code. As we learned, we are going to download it, configure it to target the emulator, build it, and try it on the device.

Setup

Let's set up our WORKING_DIRECTORY and download our precious source code. Open a Terminal and run the following commands:

:$ mkdir WORKING_DIRECTORY
:$ cd WORKING_DIRECTORY
:$ repo init –u https://android.googlesource.com/platform/manifest -b 
android-5.1.1_r9
:$ repo sync

After the download is completed, we can configure the environment. Let's run:

:$ build/envsetup.sh

This will create all those handy tools we will need during the work. We now have lunch, for instance, and running it we can keep on configuring the environment:

:$ lunch

Let's choose a target device:

aosp_arm-eng

The lunch command will set up everything and show us a configuration report, as shown in the next screenshot:

Setup

Build

Everything is in place. We need only one command to launch the build procedure:

:$ make –j8

Once the build process is over, head to out/target/product/generic/. This folder will contain our built images. The following screenshot shows the result of the build process: a folder full of .img files, ready to be flashed into the device:

Build

Run

To launch the emulator, Android provides the emulator command. This command will be available the moment the compilation ends. Using the .img files, we have in the out/ folder, we can run it like this:

$ emulator -system out/target/product/generic/system.img -ramdisk out/target/product/generic/ramdisk.img -data out/target/product/generic/userdata-qemu.img

After a few moments, the emulator window will pop up and you will see something like the following screenshot:

Run

You can use the emulator with mouse and keyboard, performing the same operations you would do on a real device. Android emulator is a powerful tool and the amount of possibilities is almost endless. If you would like to dig into the topic, the Android Developers website provides a specific page for it: http://developer.android.com/tools/help/emulator.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.36.221