1Copyright (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 16Subject: How to build an Android SDK & ADT Eclipse plugin. 17Date: 2009/03/27 18Updated: 2015/09/09 19 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/source/download.html 72 73For 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 80Then 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 87This will take a while, maybe between 20 minutes and several hours depending on 88your 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 92Some 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------------------------------ 1103- Building an SDK for Windows 111------------------------------ 112 113Full Windows SDK builds are now only supported on Linux -- most of the 114framework is not designed to be built on Windows so technically the Windows 115SDK is build on top of a Linux SDK where a few binaries are replaced. So it 116cannot be built on Windows, and it cannot be built on Mac, only on Linux. 117 118I'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 123A- Pre-requisites 124----------------- 125 126Before you can even think of building the Android SDK for Windows, you need to 127perform the steps from section "2- Building an SDK for MacOS and Linux" above: 128setup and build a regular Linux SDK. Once this working, please continue here. 129 130Under Ubuntu, you will need the following extra packages: 131 132$ sudo apt-get install tofrodos 133 134tofrodos adds a unix2dos command 135 136 137B- Building 138----------- 139 140To build, perform the following steps: 141 142$ . build/envsetup.sh 143$ lunch sdk-eng 144$ make win_sdk 145 146Note that this will build both a Linux SDK then a Windows SDK. 147The result is located at 148 out/host/windows/sdk/android-sdk_eng.${USER}_windows/ 149 150 151C- Building just the tools 152-------------------------------------- 153 154You can also build isolated windows tools directly on Linux without building 155the full SDK. 156 157To build, perform the following steps: 158 159 $ cd ~/my-android-git 160 $ . build/envsetup.sh 161 $ lunch sdk-eng 162 $ make winsdk-tools 163 164A specific tool can be built using: 165 166 $ make host_cross_adb 167 168Then the binaries are located at 169 out/host/windows-x86/bin/adb.exe 170 171 172------------------------------------- 1734- Building an ADT plugin for Eclipse 174------------------------------------- 175 176We've simplified the steps here. 177It used to be that you'd have to download a specific version of 178Eclipse and install it at a special location. That's not needed 179anymore. 180 181Instead you just change directories to your git repository and invoke the 182build 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 189The first argument is the destination directory. It must be absolute. Do not 190give a relative destination directory such as "../mysdk" -- this would make the 191Eclipse 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 199The second argument is the build "number". The example used "$USER" but it 200really is a free identifier of your choice. It cannot contain spaces nor 201periods (dashes are ok.) If the build number is missing, a build timestamp will 202be used instead in the filename. 203 204The build should take something like 5-10 minutes. 205 206 207When the build succeeds, you'll see something like this at the end of the 208output: 209 210 ZIP of Update site available at ~/mysdk/android-eclipse-v200903272328.zip 211or 212 ZIP of Update site available at ~/mysdk/android-eclipse-<buildnumber>.zip 213 214When 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 216internal plugin ID is always composed of the package, the build timestamp and 217then your own build identifier (a.k.a. the "build number"), if provided. This 218means successive builds with the same build identifier are incremental and 219Eclipse will know how to update to more recent ones. 220 221 222 223------------- 2245- Conclusion 225------------- 226 227This completes the howto guide on building your own SDK and ADT plugin. 228Feedback is welcome on the public Android Open Source forums: 229 http://source.android.com/discuss 230 231If you are upgrading from a pre-cupcake to a cupcake or later SDK please read 232the accompanying document "howto_use_cupcake_sdk.txt". 233 234-end- 235 236