首页 > 代码库 > Android Automotive开发之一《编译自己的SDK 》

Android Automotive开发之一《编译自己的SDK 》

 

自己动手编译最新Android源码及SDK : http://blog.csdn.net/dd864140130/article/details/51718187
官方文档,怎样编译sdk : https://android.googlesource.com/platform/sdk/+/master/docs/howto_build_SDK.txt

 

Android N Car源码到手,但官方还没有发布最新的SDK,源码中开发应用就有很大的难度,有了自己的SDK,无论framework层如何变动,都可以在Android Studio中开发得心应手。

 

Copyright (C) 2009 The Android Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at     http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.Subject: How to build an Android SDK & ADT Eclipse plugin.Date:    2009/03/27Updated: 2015/09/09Table of content:  0- License  1- Foreword  2- Building an SDK for MacOS and Linux  3- Building an SDK for Windows  4- Building an ADT plugin for Eclipse  5- Conclusion----------0- License---------- Copyright (C) 2009 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.-----------1- Foreword-----------This document explains how to build the Android SDK and the ADT Eclipse plugin.It is designed for advanced users which are proficient with command-lineoperations and know how to setup the pre-required software.Basically its not trivial yet when done right its not that complicated.--------------------------------------2- Building an SDK for MacOS and Linux--------------------------------------First, setup your development environment and get the Android source code fromgit as explained here:  http://source.android.com/source/download.htmlFor example for the cupcake branch:  $ mkdir ~/my-android-git  $ cd ~/my-android-git  $ repo init -u https://android.googlesource.com/platform/manifest -b master -g all,-notdefault,tools  $ repo syncThen once you have all the source, simply build the SDK using:  $ cd ~/my-android-git  $ . build/envsetup.sh  $ lunch sdk-eng  $ make sdkThis will take a while, maybe between 20 minutes and several hours depending onyour machine. After a while youll see this in the output:  Package SDK: out/host/darwin-x86/sdk/android-sdk_eng.<build-id>_mac-x86.zipSome options:- Depending on your machine you can tell make to build more things in  parallel, e.g. if you have a dual core, use "make -j4 sdk" to build faster.- You can define "BUILD_NUMBER" to control the build identifier that gets  incorporated in the resulting archive. The default is to use your username.  One suggestion is to include the date, e.g.:  $ export BUILD_NUMBER=${USER}-`date +%Y%m%d-%H%M%S`  There are certain characters you should avoid in the build number, typically  everything that might confuse make or your shell. So for example avoid  punctuation and characters like $ & : / \ < > , and .------------------------------3- Building an SDK for Windows------------------------------Full Windows SDK builds are now only supported on Linux -- most of theframework is not designed to be built on Windows so technically the WindowsSDK is build on top of a Linux SDK where a few binaries are replaced. So itcannot be built on Windows, and it cannot be built on Mac, only on Linux.Ill repeat this again because its important:  To build the Android SDK for Windows, you need to use a *Linux* box.A- Pre-requisites-----------------Before you can even think of building the Android SDK for Windows, you need toperform the steps from section "2- Building an SDK for MacOS and Linux" above:setup and build a regular Linux SDK. Once this working, please continue here.Under Ubuntu, you will need the following extra packages:$ sudo apt-get install tofrodostofrodos adds a unix2dos commandB- Building-----------To build, perform the following steps:$ . build/envsetup.sh$ lunch sdk-eng$ make win_sdkNote that this will build both a Linux SDK then a Windows SDK.The result is located at   out/host/windows/sdk/android-sdk_eng.${USER}_windows/C- Building just the tools--------------------------------------You can also build isolated windows tools directly on Linux without buildingthe full SDK.To build, perform the following steps:  $ cd ~/my-android-git  $ . build/envsetup.sh  $ lunch sdk-eng  $ make winsdk-toolsA specific tool can be built using:  $ make host_cross_adbThen the binaries are located at  out/host/windows-x86/bin/adb.exe-------------------------------------4- Building an ADT plugin for Eclipse-------------------------------------Weve simplified the steps here.It used to be that youd have to download a specific version ofEclipse and install it at a special location. Thats not neededanymore.Instead you just change directories to your git repository and invoke thebuild script by giving it a destination directory and an optional build number:  $ mkdir ~/mysdk  $ cd ~/my-android-git   # <-- this is where you did your "repo sync"  $ sdk/eclipse/scripts/build_server.sh ~/mysdk $USERThe first argument is the destination directory. It must be absolute. Do notgive a relative destination directory such as "../mysdk" -- this would make theEclipse build fail with a cryptic message:  BUILD SUCCESSFUL  Total time: 1 minute 5 seconds  **** Package in ../mysdk  Error: Build failed to produce ../mysdk/android-eclipse  AbortingThe second argument is the build "number". The example used "$USER" but itreally is a free identifier of your choice. It cannot contain spaces norperiods (dashes are ok.) If the build number is missing, a build timestamp willbe used instead in the filename.The build should take something like 5-10 minutes.When the build succeeds, youll see something like this at the end of theoutput:  ZIP of Update site available at ~/mysdk/android-eclipse-v200903272328.zipor  ZIP of Update site available at ~/mysdk/android-eclipse-<buildnumber>.zipWhen you load the plugin in Eclipse, its feature and plugin name will look like"com.android.ide.eclipse.adt_0.9.0.v200903272328-<buildnumber>.jar". Theinternal plugin ID is always composed of the package, the build timestamp andthen your own build identifier (a.k.a. the "build number"), if provided. Thismeans successive builds with the same build identifier are incremental andEclipse will know how to update to more recent ones.-------------5- Conclusion-------------This completes the howto guide on building your own SDK and ADT plugin.Feedback is welcome on the public Android Open Source forums:  http://source.android.com/discussIf you are upgrading from a pre-cupcake to a cupcake or later SDK please readthe accompanying document "howto_use_cupcake_sdk.txt".-end-

 

Android Automotive开发之一《编译自己的SDK 》