Building android AOSP on Mac OS X Mountain Lion

Source: Internet
Author: User

I have been working with the Android AOSP source code for some time now and spent endless hours searching the internet for Problems that arose on different occasions. Today I decided to note them off, on the one hand it's convenient for me to just look it up on my own blog, on the other Hand you might find some of these notes useful.

What I-ran into today is upgrading from Android 4.0.3 to 4.2.2. I didn ' t expect any difficulties in compiling the new source as compiling Android 4.0.3 on my Mac OS X (Mountain Lion) wor Ked like a charm for me. But of course I discovered something disturbing-when I ran lunch 12 , I got an error:

xcrun:Error:failed to exec real xcrun. (No such file or directory) build/CORE/COMBO/HOST_DARWIN-X86.MK: +: *****************************************************Build/CORE/COMBO/HOST_DARWIN-X86.MK: the: * Cannot find SDK10.6at/developer/sdks/macosx10.6. Sdkbuild/CORE/COMBO/HOST_DARWIN-X86.MK: $: * If you wish to buildusinghigher version of the SDK, build/CORE/COMBO/HOST_DARWIN-X86.MK: the: *TrySetting build_mac_sdk_experimental=1before build/CORE/COMBO/HOST_DARWIN-X86.MK: the: * rerunning ThisCommand Build/CORE/COMBO/HOST_DARWIN-X86.MK: the: *****************************************************Build/CORE/COMBO/HOST_DARWIN-X86.MK: -: ***Stop: Stop.* * Don'T has a product spec for:'Full_maguro'* * Does the right repo manifest?
What's it complaining about hell?

Quickly looking up what Xcrun is doing I discovered it's some helper program do select the correct XCode version/sdk etc. It didn ' t suprise me that it failed as I Don has XCode installed. But why would it want somthing from XCode?

I don ' t really have a answer to that, but I discovered that some genius decided so everyone building on Mac OS X had XC Ode installed. There ' s no option nor flag nor anything else to disable the use of these XCode specific tools-at least I didn ' t find the M. However, I don ' t want to complain on it (too much) so without further ado I'll tell what to compile Android 4.2.2 On Mac OS X Mountain Lion. I'll even try to does it in a-the-it-you-can-do it-when-starting from scratch. Please keep the had my system running for a long time so I might has missed some steps when trying to Backtrac K The essentials.

Setting up the build environment

At this point I should point out of that there are an excellent documentation for setting up the environment here and If anything goes wrong you should check it and it might solve your problem.

Homebrew and Prequesites

I am using Brew to install packages. Shipped with the OS and would setup the build environment using it . Of course you whatever prefer, but I can highly recommend brew. After your system was ready for brew (check it brew doctor with), execute the following commands:

Brew Install automakebrew tap Homebrew/dupesbrew install Apple-gcc42

Moreover you has to install Java 1.6, for that just open the Terminal and type java -version . If you haven ' t installed it the system would prompt you whether your want to install it.

Prepare a virtual disk to hold the Android source

The default file system on Mac OS X is case-insensitive, meaning That  test  and  Test  would refer to the same file or directory. For some reason there be files in the the Linux kernel that differ only in the case of a letter-this was something you ' d Pro bably do after hours of not sleeping and have a few drinks, at least that's the situation I imagine when trying to GR ASP why someone would does that ... Anyhow, either you has a disk with a case-sensitive filesystem or you create a virtual disk and mount it. To create the virtual disk, mount it and enter the directory run:

' case-sensitive journaled hfs+ ' -size 40g ~/~/android.dmg.sparseimage-mountpoint/volumes//volumes/android
Downloading the source

First we need to install which are a program this repo helps to organize the git repositories.

mkdir ~/binpath=~/bin: $PATHcurl https://dl-ssl.google.com/dl/googlesource/ Git-repo/repo > ~/bin/repochmod a+x ~/bin/repo

If you have followed along, you ' re still in the root directory of the the mounted disk. If not, you'll have the to cd /Volumes/android . Finally to download the code run:

Repo init-u https://android.googlesource.com/platform/manifest-b android-4.2.2_r1.2--config-name Repo Sync

This would take a while and go do something else until it finishes.

Building for a device

These steps depend on the device you ' re building for, I'll give you the steps for   Galaxy Nexus   (Maguro) and you had to adapt them accordingly. First download the necessary drivers From the Nexus driver Page and extract them To  /Volumes/android . Now should has a directory listing similar to this one:

 $ cd/volumes/android$ lsmakefile external Libcoreabi Extract -broadcom-maguro.sh Libnativehelperbionic extract  -imgtec-maguro.sh ndkbootable extract -invensense-maguro.sh out  build extract -nxp-maguro.sh                Packagescts extract -samsung-maguro.sh Pdkdalvik            Extract -widevine-maguro.sh prebuiltsdevelopment Frameworks Sdkdevice gdk systemdocs hardware vendor  

Now run each of the extract-... shell scripts. You'll be asked to accept it license and you should (well, otherwise the drivers won ' t be extracted). Also you might has to unlock your bootloader etc. but I'll leave that to you; It ' s a well documented procedure.

Building the source code

Just to is on the safe side, the Android build scripts depend on being executed by bash therefore run it if you D On ' t already. Moreover I had problems perlbrew with if you have it installed it's d be wise to switch to the Perl version which is shipped wit H Mac OS X now.

Now there comes the time for the hack, download This file  (  android-4.2.2_r1.2 only!!!   ) and overwrite the file In  build/core/combos/host_darwin-x86.mk . I changed the file to allow for manually overriding the host Compilers  HOS T_CC  and  HOST_ CXX  and skip the Xcode test if they is both present. I don ' t use makefiles @ All so there might is a more elegant solution to the problem and this works. After you are replaced the files you can execute:

. build/envsetup.shhost_cc=gcc-4.2 host_cxx=g++-4.2  lunch make host_cc=gcc-  4.2 host_cxx=g++-4.2 -j8

This would again take a while and if you followed all the steps the compilation succeeds.

Final Notes

Most of the steps I presented here is from the official Android documentation and I recommend reading these docs For further information or troubleshooting. I hope I could help some for you:)

Building android AOSP on Mac OS X Mountain Lion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.