blob: 20e34fac8da09096cecb33013bf33a87e4424940 [file] [log] [blame] [view]
Skyler Kaufman991ae4d2011-04-07 12:30:41 -07001# Building the System #
2
3The basic sequence of build commands is as follows:
4
5## Initialize ##
6
7Initialize the environment with the `envsetup.sh` script. Note
8that replacing "source" with a single dot saves a few characters,
9and the short form is more commonly used in documentation.
10
11 $ source build/envsetup.sh
12
13or
14
15 $ . build/envsetup.sh
16
17## Choose a Target ##
18
19Choose which target to build with `lunch`. The exact configuration can be passed as
20an argument, e.g.
21
22 $ lunch full-eng
23
24Common targets include
25
26- **full-eng**: emulator build with all debugging enabled
27- **full_passion-userdebug**: passion (Nexus One) build with minimal debugging
28- **full_crespo-userdebug**: crespo (Nexus S) build with minimal debugging.
29
30If run with no arguments `lunch` will prompt you to choose a target from the menu.
31
32All build targets take the form DEVICE-BUILDTYPE, where the DEVICE is a codename
33referring to the particular hardware:
34
35Codename | Device
36-----------|-----------
37passion | Nexus One
38crespo | Nexus S
39voles | Droid
40opal | myTouch/Sapphire
41
42and the BUILDTYPE is one of the following:
43
44Buildtype | Use
45------------|--------------------------------------
46user | limited access; suited for production
47userdebug | like "user" but with `su` access; preferred for debugging
48eng | unrestricted access
49
50## Build the Code ##
51
52Build everything with `make`. GNU make can handle parallel
53tasks with a `-jN` argument, and it's common to use a number of
54tasks N that's between 1 and 2 times the number of hardware
55threads on the computer being used for the build. E.g. on a
56dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core),
57the fastest builds are made with commands between `make -j16` and
58`make -j32`.
59
60 $ make -j4
61
62## Run It! ##
63
64You can either run your build on an emulator or flash it on a device. Please note that you have already selected your build target with `lunch`, and it is unlikely at best to run on a different target than it was built for.
65
66### Flash a Device ###
67
68To flash a device, you will need to use `fastboot`, which should be included in your path after a successful build. Place the device in fastboot mode either manually by holding the appropriate key combination at boot, or from the shell with
69
70 $ adb reboot bootloader
71
72Once the device is in fastboot mode, run
73
74 $ fastboot flashall -w
75
76The `-w` option wipes the `/data` partition on the device; this is useful for your first time flashing a particular device, but is otherwise unnecessary.
77
78### Emulate an Android Device ###
79
80The emulator is added to your path automatically by the build process. To run the emulator, type
81
82 $ emulator
83
84
85# Troubleshooting Common Build Errors #
86
87## Wrong Java Version ##
88
89If you are attempting to build froyo or earlier with Java 1.6, or gingerbread or later
90with Java 1.5, `make` will abort with a message such as
91
92 ************************************************************
93 You are attempting to build with the incorrect version
94 of java.
95
96 Your version is: WRONG_VERSION.
97 The correct version is: RIGHT_VERSION.
98
99 Please follow the machine setup instructions at
100 http://source.android.com/download
101 ************************************************************
102
103This may be caused by
104
105- failing to install the correct JDK as specified on the [Initializing](initializing.html) page. Building Android requires Sun JDK 5 or 6 depending on which release you are building.
106
107- another JDK that you previously installed appearing in your path. You can remove the offending JDK from your path with:
108
109 $ export PATH=${PATH/\/path\/to\/jdk\/dir:/}
110
111## Python Version 3 ##
112
113Repo is built on particular functionality from Python 2.x and is unfortunately incompatible with Python 3. In order to use repo, please install Python 2.x:
114
115 $ apt-get install python
116
117## Gmake Version 3.82 ##
118
119There is a bug in `make` version 3.82 on Mac OS that prevents building Android.
120
121TODO: what the error looks like with GNU make 3.82 on older builds that don't explicitly detect it.
122
123Follow the instructions on the [Initializing](initializing.html) page for reverting GNU make from 3.82 to 3.81.
124
125## Case Insensitive Filesystem ##
126
127If you are building on an HFS filesystem on Mac OS X, you may encounter an error such as
128
129 ************************************************************
130 You are building on a case-insensitive filesystem.
131 Please move your source tree to a case-sensitive filesystem.
132 ************************************************************
133
134Please follow the instructions on the [Initializing](initializing.html) page for creating a case-sensitive disk image.
135
136## No USB Permission ##
137
138On most Linux systems, unprivileged users cannot access USB ports by default.
139
140TODO: what error will occur?
141
142Follow the instructions on the [Initializing](initializing.html) page for configuring USB access.
143
144If adb was already running and cannot connect to the device after
145getting those rules set up, it can be killed with `adb kill-server`.
146That will cause adb to restart with the new configuration.
147