1 Subject: How to build an Android SDK & ADT Eclipse plugin.
8 2- Building an SDK for MacOS and Linux
9 3- Building an SDK for Windows
10 4- Building an ADT plugin for Eclipse
19 Copyright (C) 2009 The Android Open Source Project
21 Licensed under the Apache License, Version 2.0 (the "License");
22 you may not use this file except in compliance with the License.
23 You may obtain a copy of the License at
25 http://www.apache.org/licenses/LICENSE-2.0
27 Unless required by applicable law or agreed to in writing, software
28 distributed under the License is distributed on an "AS IS" BASIS,
29 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 See the License for the specific language governing permissions and
31 limitations under the License.
39 This document explains how to build the Android SDK and the ADT Eclipse plugin.
41 It is designed for advanced users which are proficient with command-line
42 operations and know how to setup the pre-required software.
44 Basically it's not trivial yet when done right it's not that complicated.
48 --------------------------------------
49 2- Building an SDK for MacOS and Linux
50 --------------------------------------
52 First, setup your development environment and get the Android source code from
53 git as explained here:
55 http://source.android.com/download
57 For example for the cupcake branch:
59 $ mkdir ~/my-android-git
61 $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
64 Then once you have all the source, simply build the SDK using:
70 This will take a while, maybe between 20 minutes and several hours depending on
71 your machine. After a while you'll see this in the output:
73 Package SDK: out/host/darwin-x86/sdk/android-sdk_eng.<build-id>_mac-x86.zip
77 - Depending on your machine you can tell 'make' to build more things in
78 parallel, e.g. if you have a dual core, use "make -j4 sdk" to build faster.
80 - You can define "BUILD_NUMBER" to control the build identifier that gets
81 incorporated in the resulting archive. The default is to use your username.
82 One suggestion is to include the date, e.g.:
84 $ export BUILD_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
86 There are certain characters you should avoid in the build number, typically
87 everything that might confuse 'make' or your shell. So for example avoid
88 punctuation and characters like $ & : / \ < > , and .
92 ------------------------------
93 3- Building an SDK for Windows
94 ------------------------------
99 First you need to build an SDK for MacOS and Linux. The Windows build works by
100 updating an existing MacOS or Linux SDK zip file and replacing the unix
101 binaries by Windows binaries.
105 B- Cygwin pre-requisite & code checkout
106 ---------------------------------------
108 Second you need to install Cygwin and configure it:
109 - Get the installer at http://sources.redhat.com/cygwin/
110 - When installing Cygwin, set Default Text File Type to Unix/binary, not DOS/text.
111 This is really important, otherwise you will get errors when trying to
112 checkout code using git.
113 - Packages that you must install or not:
114 - Required packages: autoconf, bison, curl, flex, gcc, g++, git, gnupg, make,
115 mingw-zlib, python, zip, unzip.
116 - Suggested extra packages: diffutils, emacs, openssh, rsync, vim, wget.
117 - Packages that must not be installed: readline.
119 Once you installed Cygwin properly, checkout the code from git as you did
120 for MacOS or Linux. Make sure to get the same branch, and if possible keep
121 it as close to the other one as possible:
123 $ mkdir ~/my-android-git
124 $ cd ~/my-android-git
125 $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
130 C- Building the Windows SDK
131 ---------------------------
133 Now it's time to build that Windows SDK. You need:
134 - The path to the MacOS or Linux SDK zip.
135 - A directory where to place the final SDK. It will also hold some temporary
137 - The build number will be extracted from the SDK zip filename, but this will
138 only work if that build number has no underscores in it. It is suggested you
139 just define SDK_NUMBER (and not BUILD_NUMBER!) on the command line before
142 Note that the "SDK number" is really a free identifier of your choice. It
143 doesn't need to be strictly a number. As always it is suggested you avoid
144 too much punctuation and special shell/make characters. Underscores cannot
148 To summarize, the steps on the command line would be something like this:
151 $ export SDK_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
152 $ cd ~/my-android-git
153 $ development/build/tools/make_windows_sdk.sh /path/to/macos/or/linux/sdk.zip ~/mysdk
155 This will take a while to build some Windows-specific binaries, including the
156 emulator, unzip the previous zip, rename & replace things and rezip the final
157 Windows SDK zip file. A typical build time should be around 5-10 minutes.
161 -------------------------------------
162 4- Building an ADT plugin for Eclipse
163 -------------------------------------
166 - You can currently only build an ADT plugin for Eclipse under Linux.
167 - You must have a working version of Eclipse 3.4 "ganymede" RCP installed.
168 - You need X11 to run Eclipse at least once.
169 - You need a lot of patience. The trick is to do the initial setup correctly
170 once, after it's a piece of cake.
177 Note for Ubuntu or Debian users: your apt repository probably only has Eclipse
178 3.2 available and it's probably not suitable to build plugins in the first
179 place. Forget that and install a working 3.4 manually as described below.
181 - Visit http://www.eclipse.org/downloads/ to grab the
182 "Eclipse for RCP/Plug-in Developers (176 MB)" download for Linux.
183 32-bit and 64-bit versions are available, depending on your Linux installation.
185 Note: we've always used a 32-bit one, so use the 64-bit one at your own risk.
187 Note: Eclipse comes in various editions. Do yourself a favor and just stick
188 to the RCP for building this plugin. For example the J2EE contains too many
189 useless features that will get in the way, and the "Java" version lacks some
190 plugins you need to build other plugins. Please just use the RCP one.
192 - Unpack "eclipse-rcp-ganymede-SR2-linux-gtk.tar.gz" in the directory of
195 $ mkdir ~/eclipse-3.4
197 $ tar xvzf eclipse-rcp-ganymede-SR2-linux-gtk.tar.gz
199 This will create an "eclipse" directory in the current directory.
201 - Set ECLIPSE_HOME to that "eclipse" directory:
203 $ export ECLIPSE_HOME=~/eclipse-3.4/eclipse
205 Note: it is important you set ECLIPSE_HOME before starting the build.
206 Otherwise the build process will try to download and install its own Eclipse
207 installation in /buildroot, which is probably limited to root.
209 - Now, before you can build anything, it is important that you start Eclipse
210 *manually* once using the same user that you will use to build later. That's
211 because your Eclipse installation is not finished: Eclipse must be run at
212 least once to create some files in ~/.eclipse/. So run Eclipse now:
214 $ ~/eclipse-3.4/eclipse/eclipse &
216 Wait for it load, create a workspace when requested and then simply quit
217 using the File > Quit menu. That's it. You won't need to run it manually
225 Finally, you have Eclipse, it's installed and it created its own config files,
226 so now you can build your ADT plugin. To do that you'll change directories to
227 your git repository and invoke the build script by giving it a destination
228 directory and an optional build number:
231 $ cd ~/my-android-git # <-- this is where you did your "repo sync"
232 $ development/tools/eclipse/scripts/build_server.sh ~/mysdk $USER
234 The first argument is the destination directory. It must be absolute. Do not
235 give a relative destination directory such as "../mysdk". This will make the
236 Eclipse build fail with a cryptic message:
239 Total time: 1 minute 5 seconds
240 **** Package in ../mysdk
241 Error: Build failed to produce ../mysdk/android-eclipse
244 The second argument is the build "number". The example used "$USER" but it
245 really is a free identifier of your choice. It cannot contain spaces nor
246 periods (dashes are ok.) If the build number is missing, a build timestamp will
247 be used instead in the filename.
249 The build should take something like 5-10 minutes.
252 When the build succeeds, you'll see something like this at the end of the
255 ZIP of Update site available at ~/mysdk/android-eclipse-v200903272328.zip
257 ZIP of Update site available at ~/mysdk/android-eclipse-<buildnumber>.zip
259 When you load the plugin in Eclipse, its feature and plugin name will look like
260 "com.android.ide.eclipse.adt_0.9.0.v200903272328-<buildnumber>.jar". The
261 internal plugin ID is always composed of the package, the build timestamp and
262 then your own build identifier (a.k.a. the "build number"), if provided. This
263 means successive builds with the same build identifier are incremental and
264 Eclipse will know how to update to more recent ones.
272 This completes the howto guide on building your own SDK and ADT plugin.
273 Feedback is welcome on the public Android Open Source forums:
274 http://source.android.com/discuss
276 If you are upgrading from a pre-cupcake to a cupcake or later SDK please read
277 the accompanying document "howto_use_cupcake_sdk.txt".