Part of my half day tutorial on AnDevcon, November 2013, Burlingame, CA.
In this tutorial, you will have a hands-on journey of customizing and building Android for any X86-based device. We will first introduce the concepts of Android ROM cooking for any device and architecture. You will learn what Android is made of, and will build a minimal Android configuration that will run on a Virtual Machine, using the AOSP project. We will then survey the build systems of Android-X86 and 01.org's Android-IA projects, and find our ways through customizing those projects for arbitrary needs.
You will step out of the classroom with the ability to follow the exact steps made in the tutorial to jump-start building your own Android system for any Virtual Machine - and with the tools and knowledge to build it for any X86 hardware!
Note: The tutorial is extremely hands on. Although it is not a strict requirement, it is strongly recommended to come prepared with a setup of Linux or OS X with the source code for an Android platform from either source.developer.andorid.com {http://source.developer.andorid.com/}, android-x86.org {http://www.android-x86.org/} or 01.org {https://01.org/}.
LEVEL: Advanced
AUDIENCE: Embedded Android
For Training/Consulting requests: info@thepscg.com
3. Agenda
● History
● The Android Open Source Project
● Introduction to working with the AOSP
● Building your first ROM - the Android Emulator
4. ● 2002 - SideKick by Danger Inc. - The first “Internet Phone”.
○ Technical session at Stanford by Andy Rubin, CEO of Danger Inc.
○ Google’s Brin&Page attend, and soon become Sidekick users.
○ Sidekick fails to acheive commercial success
● 2003 - Andy Rubin forms “Android”, targeted at operating mobile phones
and cameras
● 2005 - Google Acquires “Android”.
● 2007 - The Open Handset Alliance is formed
○ November 5th - The OHA Announces Android, an open source
mobile phone platform based on the linux kernel
○ November 12th - Google Announces the Android SDK, along with a
$10 million Android developer challenge
Android History (2002-2007)
5. ● 2008 - T-mobile and Google announce the first Android phone - the G1
○ AKA. The HTC “Dream”
○ Approved by the FCC on August 18th 2008
○ First available - October 22nd
● 2009 - Motorola Droid is announced, running Android 2.0
○ Considered by many as the opening note for the smartphone wars.
○ Added at least two exclusive features:
■ Hardware keyboard
■ Replaceable battery
Android History (2008-2009)
6. ● 2010 was an exciting year for Android:
○ Google Announces its first flagship device - the Nexus One
■ Which is one of the best phones I have ever had.
○ Samsung sets a giant’s foot on the battlefield
■ Galaxy S and its variants hit the market
○ HTC’s EVO4G hits the market
■ Was widely considered as the best iPhone alternative at that time
○ Android’s market share first passes the iPhone’s market share
○ Google announces the Gingerbread (2.3) Android version, debuting
on the Nexus S.
■ Introducing the most popular Android version until the end of 2013
■ Introducing NFC and SIP
Android History (2010)
7. Android History (2011-2013)
● 2011 - Honeycomb (3.0), google’s first aim at the tablet market is out
○ Android’s market share first passes the Blackberry’s market share
○ November 2011 - Ice Scream Sandwich is out, debutting on the
Galaxy Nexus
● 2012 - JellyBean is released
○ Introducing significant enhancement in user experience (Project
butter)
○ Introducing multi user for tablets
○ Samsung confidently ranks as the top Android phone maker on earth
● 2013 - More devices, more market share,
○ Android 4.3 is out: Enhanced WiFi-Display, Open GL ES 3.0,...
○ Android 4.4 (KitKat) is out: First time a commercial brand pays for an
Android version branding, and more...
8. Android History (Future)
● Foreseeable future:
○ More devices
○ More power
○ More features
○ More apps
○ More developers
○ More competition
○ More embedded Android engineers required.
● Will Android be crowned as the new Embedded Linux?
9. Platform Versions
● Data collected during a 14-day period ending on August 1, 2013.
● Any versions with less than 0.1% distribution are not shown
12. Android Open Source Project
● “Semi-Open source”
○ Why “Semi” ? In next slide!
● Maintained by Google
● Contributions accepted using “gerrit”
● Mostly Apache licensed
● Provides templates for building an Android system, including
bootloaders etc.
● Vendors derive their products for their hardware layout (BSP,
binaries, etc.)
● Provides the complete source code (but usually missing proprietary
binaries) for a bunch of supported devices (e.g. Galaxy Nexus,
Nexus 4/7/10, Android Emulator)
13. Android and Open Source
● Source code (For most components) is publicly available
● Contributions are accepted
○ Sometimes. Usually takes time, really depends on the
contribution.
● “Latest and greatest” development is done behind close
doors
● No participation in project direction
14. Android and Open Source
“Open source is different than a community-driven
project.
Android is light on community-driven, somewhat
heavy on open source.” - Andy Rubin
15. Android and Open Source
● So far, history has proven that Google publishes major code
releases about every six months - close the announcement
of a new device running that new code release
● Latest and greatest open source work (that is what is not
done exclusively behind google’s close doors) can be
viewed, reviewed and contributed to:
○ http://android-review.googlesource.com/ - Gerrit.
■ View current patches
○ http://android.googlesource.com - Gitweb.
■ View state of published source
○ https://code.google.com/p/android/issues - View or submit bug, issue,
feature request
● (If at all,) Bug fixes usually make their ways to the master branch.
○ See http://source.android.com/source/submit-patches.html
16. Building the AOSP
● Minimum Requirements
○ 64-bit Linux or Mac system (HW or VM). at least 16GB of RAM/swap
○ 30GB of free disk space to complete a single build and up to 100GB or
more for a full set of builds. The source download is over 10GB in
size.
○ Python 2.6 -- 2.7, which you can download from python.org.
○ GNU Make 3.81 -- 3.82, which you can download from gnu.org,
○ JDK 6 -- 7 which you can download from oracle.com
○ Git 1.7 or newer. You can find it at git-scm.com.
● Your building life will be easy with
○ Lots of cores
○ Lots of memory
○ SSD
17. Building the AOSP - Checklist
✓ Setup your workstation (Hardware, VM)
✓ Configure all the necessary packages
○ @see http://source.android.com
✓ Configure path for “repo” tool
✓ Configure ccache
✓ Double check RAM and free disk space requirements.
18. Obtaining the source code
● The AOSP uses repo, a multi git project wrapper written in Python for
source code management.
● Before building the AOSP, or any other Android build system, one must
first decide the branch or tag they would like to work on.
○ That would be the same branch/tag for a given, public Android release
● Then, to initialize the repository configuration at their hosts one should
create a directory, change the working directory to it, and:
○ repo init -u https://android.googlesource.com/platform/manifest
■ For working on the master branch
○ repo init -u https://android.googlesource.com/platform/manifest -b <branch>
■ For working on the <branch> branch
● Once repo has been initialized with parameters such as your name and
email address, you can synchronize the code to the latest remote state:
○ repo sync -j${NumJobs}
■ The -j parameter is the number of simultaneous jobs
19. Building the source code
● Let us deal with a device supported in the AOSP (i.e. *Nexus*, or emulator)
● Once the source is ready, you first need to configure the build
environment:
○ . build/envsetup.sh
■ This will setup the base Android build system environment
● Then, you choose your specific device configuration:
○ lunch <devicename>-<variant>
■ <devicename> is the code name for the device (e.g. maguro, grouper,
full_x86) , responsible of setting the device specific configuration, BSP,
partition layout, etc.
■ <variant> Can be one of the following:
● user - production build
● userdebug - production with debug features
● eng - engineering builds
● tests - google internal
● Note: The list can be modified, and it has been (RIP “debug”)
● Once the build target has been selected - you are good to build:
○ make -j${NumJobs}
■ The -j parameter is the number of simultaneous jobs
20. Example
● Task: Build and run an Android emulator with the following properties:
○ Based on the android-4.3_r2.1 tag
○ For X86 architecture
○ -eng build variant
● Solution:
○ mkdir -p ~/edu/AOSP
○ cd ~/edu/AOSP
○ repo init -u https://android.googlesource.com/platform/manifest -b android-4.3_r2.1
○ repo sync -j4 # This will take a while...
○ . build/envsetup.sh
○ lunch aosp_x86-eng
○ make -j16 # This will take a while
○ emulator & #
21. 1 picture == 1000 words
This is an image based on one of the earliest
JB versions. Not much, if any has changed
since the very early days of “Cupcake” and
“Donut”.