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