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