blob: abd1ab2855568f540b3b1e5243adc1b9daef1be4 [file] [log] [blame]
Raphael Moll11fcb512009-03-31 14:16:11 -07001Subject: How to build an Android SDK & ADT Eclipse plugin.
2Date: 2009/03/27
3
4
5Table of content:
6 0- License
7 1- Foreword
8 2- Building an SDK for MacOS and Linux
9 3- Building an SDK for Windows
10 4- Building an ADT plugin for Eclipse
11 5- Conclusion
12
13
14
15----------
160- License
17----------
18
19 Copyright (C) 2009 The Android Open Source Project
20
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
24
25 http://www.apache.org/licenses/LICENSE-2.0
26
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.
32
33
34
35-----------
361- Foreword
37-----------
38
39This document explains how to build the Android SDK and the ADT Eclipse plugin.
40
41It is designed for advanced users which are proficient with command-line
42operations and know how to setup the pre-required software.
43
44Basically it's not trivial yet when done right it's not that complicated.
45
46
47
48--------------------------------------
492- Building an SDK for MacOS and Linux
50--------------------------------------
51
52First, setup your development environment and get the Android source code from
53git as explained here:
54
55 http://source.android.com/download
56
57For example for the cupcake branch:
58
59 $ mkdir ~/my-android-git
60 $ cd ~/my-android-git
61 $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
62 $ repo sync
63
64Then once you have all the source, simply build the SDK using:
65
66 $ cd ~/my-android-git
67 $ . build/envsetup.sh
Xavier Ducrohet728457d2010-04-15 17:26:58 -070068 $ lunch sdk-eng
Raphael Moll11fcb512009-03-31 14:16:11 -070069 $ make sdk
70
71This will take a while, maybe between 20 minutes and several hours depending on
72your machine. After a while you'll see this in the output:
73
74 Package SDK: out/host/darwin-x86/sdk/android-sdk_eng.<build-id>_mac-x86.zip
75
76Some options:
77
78- Depending on your machine you can tell 'make' to build more things in
79 parallel, e.g. if you have a dual core, use "make -j4 sdk" to build faster.
80
81- You can define "BUILD_NUMBER" to control the build identifier that gets
82 incorporated in the resulting archive. The default is to use your username.
83 One suggestion is to include the date, e.g.:
84
85 $ export BUILD_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
86
87 There are certain characters you should avoid in the build number, typically
88 everything that might confuse 'make' or your shell. So for example avoid
89 punctuation and characters like $ & : / \ < > , and .
90
91
92
93------------------------------
943- Building an SDK for Windows
95------------------------------
96
97A- SDK pre-requisite
98--------------------
99
100First you need to build an SDK for MacOS and Linux. The Windows build works by
101updating an existing MacOS or Linux SDK zip file and replacing the unix
102binaries by Windows binaries.
103
104
105
106B- Cygwin pre-requisite & code checkout
107---------------------------------------
108
109Second you need to install Cygwin and configure it:
110- Get the installer at http://sources.redhat.com/cygwin/
111- When installing Cygwin, set Default Text File Type to Unix/binary, not DOS/text.
112 This is really important, otherwise you will get errors when trying to
113 checkout code using git.
114- Packages that you must install or not:
115 - Required packages: autoconf, bison, curl, flex, gcc, g++, git, gnupg, make,
116 mingw-zlib, python, zip, unzip.
117 - Suggested extra packages: diffutils, emacs, openssh, rsync, vim, wget.
118 - Packages that must not be installed: readline.
119
120Once you installed Cygwin properly, checkout the code from git as you did
121for MacOS or Linux. Make sure to get the same branch, and if possible keep
122it as close to the other one as possible:
123
124 $ mkdir ~/my-android-git
125 $ cd ~/my-android-git
126 $ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
127 $ repo sync
128
129
130
131C- Building the Windows SDK
132---------------------------
133
134Now it's time to build that Windows SDK. You need:
135- The path to the MacOS or Linux SDK zip.
136- A directory where to place the final SDK. It will also hold some temporary
137 files.
138- The build number will be extracted from the SDK zip filename, but this will
139 only work if that build number has no underscores in it. It is suggested you
140 just define SDK_NUMBER (and not BUILD_NUMBER!) on the command line before
141 invoking the script.
142
143 Note that the "SDK number" is really a free identifier of your choice. It
144 doesn't need to be strictly a number. As always it is suggested you avoid
145 too much punctuation and special shell/make characters. Underscores cannot
146 be used.
147
148
149To summarize, the steps on the command line would be something like this:
150
151 $ mkdir ~/mysdk
152 $ export SDK_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
153 $ cd ~/my-android-git
154 $ development/build/tools/make_windows_sdk.sh /path/to/macos/or/linux/sdk.zip ~/mysdk
155
156This will take a while to build some Windows-specific binaries, including the
157emulator, unzip the previous zip, rename & replace things and rezip the final
158Windows SDK zip file. A typical build time should be around 5-10 minutes.
159
160
161
162-------------------------------------
1634- Building an ADT plugin for Eclipse
164-------------------------------------
165
166Requirements:
167- You can currently only build an ADT plugin for Eclipse under Linux.
168- You must have a working version of Eclipse 3.4 "ganymede" RCP installed.
169- You need X11 to run Eclipse at least once.
170- You need a lot of patience. The trick is to do the initial setup correctly
171 once, after it's a piece of cake.
172
173
174
175A- Pre-requisites
176-----------------
177
178Note for Ubuntu or Debian users: your apt repository probably only has Eclipse
1793.2 available and it's probably not suitable to build plugins in the first
180place. Forget that and install a working 3.4 manually as described below.
181
182- Visit http://www.eclipse.org/downloads/ to grab the
183 "Eclipse for RCP/Plug-in Developers (176 MB)" download for Linux.
184 32-bit and 64-bit versions are available, depending on your Linux installation.
185
186 Note: we've always used a 32-bit one, so use the 64-bit one at your own risk.
187
188 Note: Eclipse comes in various editions. Do yourself a favor and just stick
189 to the RCP for building this plugin. For example the J2EE contains too many
190 useless features that will get in the way, and the "Java" version lacks some
191 plugins you need to build other plugins. Please just use the RCP one.
192
193- Unpack "eclipse-rcp-ganymede-SR2-linux-gtk.tar.gz" in the directory of
194 your choice, e.g.:
195
196 $ mkdir ~/eclipse-3.4
197 $ cd ~/eclipse-3.4
198 $ tar xvzf eclipse-rcp-ganymede-SR2-linux-gtk.tar.gz
199
200 This will create an "eclipse" directory in the current directory.
201
202- Set ECLIPSE_HOME to that "eclipse" directory:
203
204 $ export ECLIPSE_HOME=~/eclipse-3.4/eclipse
205
206 Note: it is important you set ECLIPSE_HOME before starting the build.
207 Otherwise the build process will try to download and install its own Eclipse
208 installation in /buildroot, which is probably limited to root.
209
210- Now, before you can build anything, it is important that you start Eclipse
211 *manually* once using the same user that you will use to build later. That's
212 because your Eclipse installation is not finished: Eclipse must be run at
213 least once to create some files in ~/.eclipse/. So run Eclipse now:
214
215 $ ~/eclipse-3.4/eclipse/eclipse &
216
217 Wait for it load, create a workspace when requested and then simply quit
218 using the File > Quit menu. That's it. You won't need to run it manually
219 again.
220
221
222
223B- Building ADT
224---------------
225
226Finally, you have Eclipse, it's installed and it created its own config files,
227so now you can build your ADT plugin. To do that you'll change directories to
228your git repository and invoke the build script by giving it a destination
229directory and an optional build number:
230
231 $ mkdir ~/mysdk
232 $ cd ~/my-android-git # <-- this is where you did your "repo sync"
233 $ development/tools/eclipse/scripts/build_server.sh ~/mysdk $USER
234
235The first argument is the destination directory. It must be absolute. Do not
236give a relative destination directory such as "../mysdk". This will make the
237Eclipse build fail with a cryptic message:
238
239 BUILD SUCCESSFUL
240 Total time: 1 minute 5 seconds
241 **** Package in ../mysdk
242 Error: Build failed to produce ../mysdk/android-eclipse
243 Aborting
244
245The second argument is the build "number". The example used "$USER" but it
246really is a free identifier of your choice. It cannot contain spaces nor
247periods (dashes are ok.) If the build number is missing, a build timestamp will
248be used instead in the filename.
249
250The build should take something like 5-10 minutes.
251
252
253When the build succeeds, you'll see something like this at the end of the
254output:
255
256 ZIP of Update site available at ~/mysdk/android-eclipse-v200903272328.zip
257or
258 ZIP of Update site available at ~/mysdk/android-eclipse-<buildnumber>.zip
259
260When you load the plugin in Eclipse, its feature and plugin name will look like
261"com.android.ide.eclipse.adt_0.9.0.v200903272328-<buildnumber>.jar". The
262internal plugin ID is always composed of the package, the build timestamp and
263then your own build identifier (a.k.a. the "build number"), if provided. This
264means successive builds with the same build identifier are incremental and
265Eclipse will know how to update to more recent ones.
266
267
268
269-------------
2705- Conclusion
271-------------
272
273This completes the howto guide on building your own SDK and ADT plugin.
274Feedback is welcome on the public Android Open Source forums:
275 http://source.android.com/discuss
276
277If you are upgrading from a pre-cupcake to a cupcake or later SDK please read
278the accompanying document "howto_use_cupcake_sdk.txt".
279
280-end-
281