xref: /aosp_15_r20/sdk/docs/howto_build_SDK.txt (revision 1789df15502f1991eff51ff970dce5df8404dd56)
1*1789df15SXin LiCopyright (C) 2009 The Android Open Source Project
2*1789df15SXin Li
3*1789df15SXin LiLicensed under the Apache License, Version 2.0 (the "License");
4*1789df15SXin Liyou may not use this file except in compliance with the License.
5*1789df15SXin LiYou may obtain a copy of the License at
6*1789df15SXin Li
7*1789df15SXin Li     http://www.apache.org/licenses/LICENSE-2.0
8*1789df15SXin Li
9*1789df15SXin LiUnless required by applicable law or agreed to in writing, software
10*1789df15SXin Lidistributed under the License is distributed on an "AS IS" BASIS,
11*1789df15SXin LiWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*1789df15SXin LiSee the License for the specific language governing permissions and
13*1789df15SXin Lilimitations under the License.
14*1789df15SXin Li
15*1789df15SXin Li
16*1789df15SXin LiSubject: How to build an Android SDK & ADT Eclipse plugin.
17*1789df15SXin LiDate:    2009/03/27
18*1789df15SXin LiUpdated: 2015/09/09
19*1789df15SXin Li
20*1789df15SXin Li
21*1789df15SXin LiTable of content:
22*1789df15SXin Li  0- License
23*1789df15SXin Li  1- Foreword
24*1789df15SXin Li  2- Building an SDK for MacOS and Linux
25*1789df15SXin Li  3- Building an SDK for Windows
26*1789df15SXin Li  4- Building an ADT plugin for Eclipse
27*1789df15SXin Li  5- Conclusion
28*1789df15SXin Li
29*1789df15SXin Li
30*1789df15SXin Li
31*1789df15SXin Li----------
32*1789df15SXin Li0- License
33*1789df15SXin Li----------
34*1789df15SXin Li
35*1789df15SXin Li Copyright (C) 2009 The Android Open Source Project
36*1789df15SXin Li
37*1789df15SXin Li Licensed under the Apache License, Version 2.0 (the "License");
38*1789df15SXin Li you may not use this file except in compliance with the License.
39*1789df15SXin Li You may obtain a copy of the License at
40*1789df15SXin Li
41*1789df15SXin Li      http://www.apache.org/licenses/LICENSE-2.0
42*1789df15SXin Li
43*1789df15SXin Li Unless required by applicable law or agreed to in writing, software
44*1789df15SXin Li distributed under the License is distributed on an "AS IS" BASIS,
45*1789df15SXin Li WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46*1789df15SXin Li See the License for the specific language governing permissions and
47*1789df15SXin Li limitations under the License.
48*1789df15SXin Li
49*1789df15SXin Li
50*1789df15SXin Li
51*1789df15SXin Li-----------
52*1789df15SXin Li1- Foreword
53*1789df15SXin Li-----------
54*1789df15SXin Li
55*1789df15SXin LiThis document explains how to build the Android SDK and the ADT Eclipse plugin.
56*1789df15SXin Li
57*1789df15SXin LiIt is designed for advanced users which are proficient with command-line
58*1789df15SXin Lioperations and know how to setup the pre-required software.
59*1789df15SXin Li
60*1789df15SXin LiBasically it's not trivial yet when done right it's not that complicated.
61*1789df15SXin Li
62*1789df15SXin Li
63*1789df15SXin Li
64*1789df15SXin Li--------------------------------------
65*1789df15SXin Li2- Building an SDK for MacOS and Linux
66*1789df15SXin Li--------------------------------------
67*1789df15SXin Li
68*1789df15SXin LiFirst, setup your development environment and get the Android source code from
69*1789df15SXin Ligit as explained here:
70*1789df15SXin Li
71*1789df15SXin Li  http://source.android.com/source/download.html
72*1789df15SXin Li
73*1789df15SXin LiFor example for the cupcake branch:
74*1789df15SXin Li
75*1789df15SXin Li  $ mkdir ~/my-android-git
76*1789df15SXin Li  $ cd ~/my-android-git
77*1789df15SXin Li  $ repo init -u https://android.googlesource.com/platform/manifest -b master -g all,-notdefault,tools
78*1789df15SXin Li  $ repo sync
79*1789df15SXin Li
80*1789df15SXin LiThen once you have all the source, simply build the SDK using:
81*1789df15SXin Li
82*1789df15SXin Li  $ cd ~/my-android-git
83*1789df15SXin Li  $ . build/envsetup.sh
84*1789df15SXin Li  $ lunch sdk-eng
85*1789df15SXin Li  $ make sdk
86*1789df15SXin Li
87*1789df15SXin LiThis will take a while, maybe between 20 minutes and several hours depending on
88*1789df15SXin Liyour machine. After a while you'll see this in the output:
89*1789df15SXin Li
90*1789df15SXin Li  Package SDK: out/host/darwin-x86/sdk/android-sdk_eng.<build-id>_mac-x86.zip
91*1789df15SXin Li
92*1789df15SXin LiSome options:
93*1789df15SXin Li
94*1789df15SXin Li- Depending on your machine you can tell 'make' to build more things in
95*1789df15SXin Li  parallel, e.g. if you have a dual core, use "make -j4 sdk" to build faster.
96*1789df15SXin Li
97*1789df15SXin Li- You can define "BUILD_NUMBER" to control the build identifier that gets
98*1789df15SXin Li  incorporated in the resulting archive. The default is to use your username.
99*1789df15SXin Li  One suggestion is to include the date, e.g.:
100*1789df15SXin Li
101*1789df15SXin Li  $ export BUILD_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`
102*1789df15SXin Li
103*1789df15SXin Li  There are certain characters you should avoid in the build number, typically
104*1789df15SXin Li  everything that might confuse 'make' or your shell. So for example avoid
105*1789df15SXin Li  punctuation and characters like $ & : / \ < > , and .
106*1789df15SXin Li
107*1789df15SXin Li
108*1789df15SXin Li
109*1789df15SXin Li------------------------------
110*1789df15SXin Li3- Building an SDK for Windows
111*1789df15SXin Li------------------------------
112*1789df15SXin Li
113*1789df15SXin LiFull Windows SDK builds are now only supported on Linux -- most of the
114*1789df15SXin Liframework is not designed to be built on Windows so technically the Windows
115*1789df15SXin LiSDK is build on top of a Linux SDK where a few binaries are replaced. So it
116*1789df15SXin Licannot be built on Windows, and it cannot be built on Mac, only on Linux.
117*1789df15SXin Li
118*1789df15SXin LiI'll repeat this again because it's important:
119*1789df15SXin Li
120*1789df15SXin Li  To build the Android SDK for Windows, you need to use a *Linux* box.
121*1789df15SXin Li
122*1789df15SXin Li
123*1789df15SXin LiA- Pre-requisites
124*1789df15SXin Li-----------------
125*1789df15SXin Li
126*1789df15SXin LiBefore you can even think of building the Android SDK for Windows, you need to
127*1789df15SXin Liperform the steps from section "2- Building an SDK for MacOS and Linux" above:
128*1789df15SXin Lisetup and build a regular Linux SDK. Once this working, please continue here.
129*1789df15SXin Li
130*1789df15SXin LiUnder Ubuntu, you will need the following extra packages:
131*1789df15SXin Li
132*1789df15SXin Li$ sudo apt-get install tofrodos
133*1789df15SXin Li
134*1789df15SXin Litofrodos adds a unix2dos command
135*1789df15SXin Li
136*1789df15SXin Li
137*1789df15SXin LiB- Building
138*1789df15SXin Li-----------
139*1789df15SXin Li
140*1789df15SXin LiTo build, perform the following steps:
141*1789df15SXin Li
142*1789df15SXin Li$ . build/envsetup.sh
143*1789df15SXin Li$ lunch sdk-eng
144*1789df15SXin Li$ make win_sdk
145*1789df15SXin Li
146*1789df15SXin LiNote that this will build both a Linux SDK then a Windows SDK.
147*1789df15SXin LiThe result is located at
148*1789df15SXin Li   out/host/windows/sdk/android-sdk_eng.${USER}_windows/
149*1789df15SXin Li
150*1789df15SXin Li
151*1789df15SXin LiC- Building just the tools
152*1789df15SXin Li--------------------------------------
153*1789df15SXin Li
154*1789df15SXin LiYou can also build isolated windows tools directly on Linux without building
155*1789df15SXin Lithe full SDK.
156*1789df15SXin Li
157*1789df15SXin LiTo build, perform the following steps:
158*1789df15SXin Li
159*1789df15SXin Li  $ cd ~/my-android-git
160*1789df15SXin Li  $ . build/envsetup.sh
161*1789df15SXin Li  $ lunch sdk-eng
162*1789df15SXin Li  $ make winsdk-tools
163*1789df15SXin Li
164*1789df15SXin LiA specific tool can be built using:
165*1789df15SXin Li
166*1789df15SXin Li  $ make host_cross_adb
167*1789df15SXin Li
168*1789df15SXin LiThen the binaries are located at
169*1789df15SXin Li  out/host/windows-x86/bin/adb.exe
170*1789df15SXin Li
171*1789df15SXin Li
172*1789df15SXin Li-------------------------------------
173*1789df15SXin Li4- Building an ADT plugin for Eclipse
174*1789df15SXin Li-------------------------------------
175*1789df15SXin Li
176*1789df15SXin LiWe've simplified the steps here.
177*1789df15SXin LiIt used to be that you'd have to download a specific version of
178*1789df15SXin LiEclipse and install it at a special location. That's not needed
179*1789df15SXin Lianymore.
180*1789df15SXin Li
181*1789df15SXin LiInstead you just change directories to your git repository and invoke the
182*1789df15SXin Libuild script by giving it a destination directory and an optional build number:
183*1789df15SXin Li
184*1789df15SXin Li  $ mkdir ~/mysdk
185*1789df15SXin Li  $ cd ~/my-android-git   # <-- this is where you did your "repo sync"
186*1789df15SXin Li  $ sdk/eclipse/scripts/build_server.sh ~/mysdk $USER
187*1789df15SXin Li
188*1789df15SXin Li
189*1789df15SXin LiThe first argument is the destination directory. It must be absolute. Do not
190*1789df15SXin Ligive a relative destination directory such as "../mysdk" -- this would make the
191*1789df15SXin LiEclipse build fail with a cryptic message:
192*1789df15SXin Li
193*1789df15SXin Li  BUILD SUCCESSFUL
194*1789df15SXin Li  Total time: 1 minute 5 seconds
195*1789df15SXin Li  **** Package in ../mysdk
196*1789df15SXin Li  Error: Build failed to produce ../mysdk/android-eclipse
197*1789df15SXin Li  Aborting
198*1789df15SXin Li
199*1789df15SXin LiThe second argument is the build "number". The example used "$USER" but it
200*1789df15SXin Lireally is a free identifier of your choice. It cannot contain spaces nor
201*1789df15SXin Liperiods (dashes are ok.) If the build number is missing, a build timestamp will
202*1789df15SXin Libe used instead in the filename.
203*1789df15SXin Li
204*1789df15SXin LiThe build should take something like 5-10 minutes.
205*1789df15SXin Li
206*1789df15SXin Li
207*1789df15SXin LiWhen the build succeeds, you'll see something like this at the end of the
208*1789df15SXin Lioutput:
209*1789df15SXin Li
210*1789df15SXin Li  ZIP of Update site available at ~/mysdk/android-eclipse-v200903272328.zip
211*1789df15SXin Lior
212*1789df15SXin Li  ZIP of Update site available at ~/mysdk/android-eclipse-<buildnumber>.zip
213*1789df15SXin Li
214*1789df15SXin LiWhen you load the plugin in Eclipse, its feature and plugin name will look like
215*1789df15SXin Li"com.android.ide.eclipse.adt_0.9.0.v200903272328-<buildnumber>.jar". The
216*1789df15SXin Liinternal plugin ID is always composed of the package, the build timestamp and
217*1789df15SXin Lithen your own build identifier (a.k.a. the "build number"), if provided. This
218*1789df15SXin Limeans successive builds with the same build identifier are incremental and
219*1789df15SXin LiEclipse will know how to update to more recent ones.
220*1789df15SXin Li
221*1789df15SXin Li
222*1789df15SXin Li
223*1789df15SXin Li-------------
224*1789df15SXin Li5- Conclusion
225*1789df15SXin Li-------------
226*1789df15SXin Li
227*1789df15SXin LiThis completes the howto guide on building your own SDK and ADT plugin.
228*1789df15SXin LiFeedback is welcome on the public Android Open Source forums:
229*1789df15SXin Li  http://source.android.com/discuss
230*1789df15SXin Li
231*1789df15SXin LiIf you are upgrading from a pre-cupcake to a cupcake or later SDK please read
232*1789df15SXin Lithe accompanying document "howto_use_cupcake_sdk.txt".
233*1789df15SXin Li
234*1789df15SXin Li-end-
235*1789df15SXin Li
236