国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
在Ubuntu上下載、編譯和安裝Android最新源代碼

在Ubuntu上下載、編譯和安裝Android最新源代碼

http://blog.csdn.net/hens007/article/details/7428691

官網(wǎng)內(nèi)容:


Initializing a Build Environment

The "Getting Started" section describes how to set up your local work environment, how to use Repo to get the Android files, and how to build the files on your machine. To build the Android source files, you will need to use Linux or Mac OS. Building under Windows is not currently supported.

Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 80GB (or more) for a full set of builds.

For an overview of the entire code-review and code-update process, see Life of a Patch.

Setting up a Linux build environment

The Android build is routinely tested in house on recent versions of Ubuntu LTS (10.04), but most distributions should have the required build tools available. Reports of successes or failures on other distributions are welcome.

Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree.

In general you will need:

  • Python 2.4 -- 2.7, which you can download from python.org.

  • JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com.

  • Git 1.7 or newer. You can find it at git-scm.com.

Detailed instructions for Ubuntu 10.04+ follow.

Installing the JDK

The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.

Java 6: for Gingerbread and newer

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"$ sudo apt-get update$ sudo apt-get install sun-java6-jdk

Java 5: for Froyo and older

$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"$ sudo apt-get update$ sudo apt-get install sun-java5-jdk

Installing required packages

64-bit (recommended)

$ sudo apt-get install git-core gnupg flex bison gperf build-essential   zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs   x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev   libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown   libxml2-utils

On newer versions of Ubuntu such as 11.10 you may need to do the following:

$ sudo ln -s /usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libX11.so

32-bit (experimental)

$ sudo apt-get install git-core gnupg flex bison gperf build-essential   zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev   libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown   libxml2-utils

Configuring USB Access

Under GNU/linux systems (and specifically under Ubuntu systems), regular users can't directly access USB devices by default. The system needs to be configured to allow such access.

The recommended approach is to create a file /etc/udev/rules.d/51-android.rules (as the root user) and to copy the following lines in it.must be replaced by the actual username of the user who is authorized to access the phones over USB.

# adb protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"# fastboot protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"# adb protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"# fastboot protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"# adb protocol on maguro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"# fastboot protocol on maguro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"

Those new rules take effect the next time a device is plugged in. It might therefore be necessary to unplug the device and plug it back into the computer.

This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) and Lucid Lynx (10.04.x LTS). Other versions of Ubuntu or other variants of GNU/linux might require different configurations.

Setting up a Mac OS X build environment

To build the Android files in a Mac OS environment, you need an Intel/x86 machine running MacOS 10.6 (Snow Leopard).

Android must be built on a case-sensitive file system because the sources contain files that differ only in case. We recommend that you build Android on a partition that has been formatted with the journaled file system HFS+. HFS+ is required to successfully build Mac OS applications such as the Android Emulator for OS X.

Creating a case sensitive disk image

If you want to avoid partitioning/formatting your hard drive, you can use a case-sensitive disk image instead. To create the image, launch Disk Utility and select "New Image". A size of 25GB is the minimum to complete the build, larger numbers are more future-proof. Using sparse images saves space while allowing to grow later as the need arises. Be sure to select "case sensitive, journaled" as the volume format.

You can also create it from a shell with the following command:

# hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 40g ~/android.dmg

This will create a .dmg (or possibly a .dmg.sparsefile) file which, once mounted, acts as a drive with the required formatting for Android development. For a disk image named "android.dmg" stored in your home directory, you can add the following to your ~/.bash_profile to mount the image when you execute "mountAndroid":

# mount the android file imagefunction mountAndroid { hdiutil attach ~/android.dmg -mountpoint /Volumes/android; }

Once mounted, you'll do all your work in the "android" volume. You can eject it (unmount it) just like you would with an external drive.

Installing required packages

  • Install XCode from the Apple developer site. We recommend version 3.1.4 or newer, i.e. gcc 4.2. Version 4.x could cause difficulties. If you are not already registered as an Apple developer, you will have to create an Apple ID in order to download.

  • Install MacPorts from macports.org.

    Note: Make sure that /opt/local/bin appears in your path BEFORE /usr/bin. If not, add

    export PATH=/opt/local/bin:$PATH

    to your ~/.bash_profile.

  • Get make, git, and GPG packages from MacPorts:

    $ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg

    If using Mac OS 10.4, also install bison:

    $ POSIXLY_CORRECT=1 sudo port install bison

Reverting from make 3.82

There is a bug in gmake 3.82 that prevents android from building. You can install version 3.81 using MacPorts by taking the following steps:

  • Edit /opt/local/etc/macports/sources.conf and add a line that says

    file:///Users/Shared/dports

    above the rsync line. Then create this directory:

    $ mkdir /Users/Shared/dports
  • In the new dports directory, run

    $ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
  • Create a port index for your new local repository:

    $ portindex /Users/Shared/dports
  • Finally, install the old version of gmake with

    $ sudo port install gmake @3.81

Setting a file descriptor limit

On MacOS the default limit on the number of simultaneous file descriptors open is too low and a highly parallel build process may exceed this limit.

To increase the cap, add the following lines to your ~/.bash_profile:

# set the number of open files to be 1024ulimit -S -n 1024

Downloading the Source Tree

Installing Repo

Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Version Control.

To install, initialize, and configure Repo, follow these steps:

  • Make sure you have a bin/ directory in your home directory, and that it is included in your path:

    $ mkdir ~/bin$ PATH=~/bin:$PATH
  • Download the Repo script and ensure it is executable:

    $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo$ chmod a+x ~/bin/repo
  • The SHA-1 checksum for repo is e1fd3bef059d152edf4d0522590725d317bc637f

Initializing a Repo client

After installing Repo, set up your client to access the android source repository:

  • Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:

    $ mkdir WORKING_DIRECTORY$ cd WORKING_DIRECTORY
  • Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.

    $ repo init -u https://android.googlesource.com/platform/manifest

    To check out a branch other than "master", specify it with -b:

    $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
  • When prompted, please configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.

A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo directory where files such as the manifest will be kept.

Getting the files

To pull down files to your working directory from the repositories as specified in the default manifest, run

$ repo sync

The Android source files will be located in your working directory under their project names. The initial sync operation will take an hour or more to complete. For more about repo sync and other Repo commands, see Version Control.

Verifying Git Tags

Load the following public key into your GnuPG key database. The key is used to sign annotated tags that represent releases.

$ gpg --import

Copy and paste the key(s) below, then enter EOF (Ctrl-D) to end the input and process the keys.

-----BEGIN PGP PUBLIC KEY BLOCK-----Version: GnuPG v1.4.2.2 (GNU/Linux)mQGiBEnnWD4RBACt9/h4v9xnnGDou13y3dvOx6/t43LPPIxeJ8eX9WB+8LLuROSVlFhpHawsVAcFlmi7f7jdSRF+OvtZL9ShPKdLfwBJMNkU66/TZmPewS4m782ndtw78tR1cXb197Ob8kOfQB3A9yk2XZ4ei4ZC3i6wVdqHLRxABdncwu5hOF9KXwCgkxMDu4PVgChaAJzTYJ1EG+UYBIUEAJmfearb0qRAN7dEoff0FeXsEaUA6U90sEoVks0ZwNj96SA8BL+a1OoEUUfpMhiHyLuQSftxisJxTh+2QclzDviDyaTrkANjdYY7p2cq/HMdOY7LJlHaqtXmZxXjjtw5Uc2QG8UY8aziU3IE9nTjSwCXeJnuyvoizl9/I1S5jU5SA/9WwIps4SC84ielIXiGWEqq6i6/sk4I9q1YemZF2XVVKnmI1F4iCMtNKsR4MGSa1gA8s4iQbsKNWPgp7M3a51JCVCu6l/8zTpA+uUGapw4tWCp4o0dpIvDPBEa9b/aF/ygcR8mh5hgUfpF9IpXdknOsbKCvM9lSSfRciETykZc4wrRCVGhlIEFuZHJvaWQgT3BlbiBTb3VyY2UgUHJvamVjdCA8aW5pdGlhbC1jb250cmlidXRpb25AYW5kcm9pZC5jb20+iGAEExECACAFAknnWD4CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAKCRDorT+BmrEOeNr+AJ42Xy6tEW7r3KzrJxnRX8mij9z8tgCdFfQYiHpYngkI2t09Ed+9Bm4gmEO5Ag0ESedYRBAIAKVW1JcMBWvV/0Bo9WiByJ9WJ5swMN36/vAlQN4mWRhfzDOk/Rosdb0csAO/l8Kz0gKQPOfObtyYjvI8JMC3rmi+LIvSUT9806UphisyEmmHv6U8gUb/xHLIanXGxwhYzjgeuAXVCsv+EvoPIHbY4L/KvP5x+oCJIDbkC2b1TvVk9PryzmE4BPIQL/NtgR1oLWm/uWR9zRUFtBnE411aMAN3qnAHBBMZzKMXLWBGWE0znfRrnczI5p49i2YZJAjyX1P2WzmScK49CV82dzLo71MnrF6fj+Udtb5+OgTg7Cow+8PRaTkJEW5Y2JIZpnRUq0CYxAmHYX79EMKHDSThf/8AAwUIAJPWsB/MpK+KMs/s3r6nJrnYLTfdZhtmQXimpoDMJg1zxmL8UfNUKiQZ6esoAWtDgpqt7Y7sKZ8laHRARonte394hidZzM5nb6hQvpPjt2OlPRsyqVxw4c/KsjADtAuKW9/d8phbN8bTyOJo856qg4oOEzKG9eeF7oaZTYBy33BTL0408sEBxiMior6b8LrZrAhkqDjAvUXRwm/fFKgpsOysxC6xi553CxBUCH2omNV6Ka1LNMwzSp9ILz8jEGqmUtkBszwoG1S8fXgE0Lq3cdDM/GJ4QXP/p6LiwNF99faDMTV3+2SAOGvytOX6KjKVzKOSsfJQhN0DlsIw8hqJc0WISQQYEQIACQUCSedYRAIbDAAKCRDorT+BmrEOeCUOAJ9qmR0lEXzeoxcdoafxqf6gZlJZlACgkWF7wi2YLW3Oa+jv2QSTlrx4KLM==Wi5D-----END PGP PUBLIC KEY BLOCK-----

After importing the keys, you can verify any tag with

$ git tag -v TAG_NAME

Building the System

The basic sequence of build commands is as follows:

Initialize

Initialize the environment with the envsetup.sh script. Note that replacing "source" with a single dot saves a few characters, and the short form is more commonly used in documentation.

$ source build/envsetup.sh

or

$ . build/envsetup.sh

Choose a Target

Choose which target to build with lunch. The exact configuration can be passed as an argument, e.g.

$ lunch full-eng

The example above refers to a complete build for the emulator, with all debugging enabled.

If run with no arguments lunch will prompt you to choose a target from the menu.

All build targets take the form BUILD-BUILDTYPE, where the BUILD is a codename referring to the particular feature combination:

Build nameDeviceNotes
fullemulatorfully configured with all languages, apps, input methods
full_maguromagurofull build running on Galaxy Nexus GSM/HSPA+ ("maguro")
full_pandapandafull build running on PandaBoard ("panda")

and the BUILDTYPE is one of the following:

BuildtypeUse
userlimited access; suited for production
userdebuglike "user" but with root access and debuggability; preferred for debugging
engdevelopment configuration with additional debugging tools

For more information about building for and running on actual hardware, see Building for devices

Build the Code

Build everything with make. GNU make can handle parallel tasks with a -jN argument, and it's common to use a number of tasks N that's between 1 and 2 times the number of hardware threads on the computer being used for the build. E.g. on a dual-E5520 machine (2 CPUs, 4 cores per CPU, 2 threads per core), the fastest builds are made with commands between make -j16 and make -j32.

$ make -j4

Run It!

You can either run your build on an emulator or flash it on a device. Please note that you have already selected your build target with lunch, and it is unlikely at best to run on a different target than it was built for.

Flash a Device

To flash a device, you will need to use fastboot, which should be included in your path after a successful build. Place the device in fastboot mode either manually by holding the appropriate key combination at boot, or from the shell with

$ adb reboot bootloader

Once the device is in fastboot mode, run

$ fastboot flashall -w

The -w option wipes the /data partition on the device; this is useful for your first time flashing a particular device, but is otherwise unnecessary.

For more information about building for and running on actual hardware, see Building for devices

Emulate an Android Device

The emulator is added to your path automatically by the build process. To run the emulator, type

$ emulator

Using ccache

ccache is a compiler cache for C and C++ that can help make builds faster. In the root of the source tree, do the following:

$ export USE_CCACHE=1$ export CCACHE_DIR=/<path_of_your_choice>/.ccache$ prebuilt/linux-x86/ccache/ccache -M 20G

You can watch ccache being used by doing the following:

$ watch -n1 -d prebuilt/linux-x86/ccache/ccache -s

On OSX, you should replace linux-x86 with darwin-x86.

Troubleshooting Common Build Errors

Wrong Java Version

If you are attempting to build froyo or earlier with Java 1.6, or gingerbread or later with Java 1.5, make will abort with a message such as

************************************************************You are attempting to build with the incorrect versionof java.Your version is: WRONG_VERSION.The correct version is: RIGHT_VERSION.Please follow the machine setup instructions at    http://source.android.com/download************************************************************

This may be caused by

  • failing to install the correct JDK as specified on the Initializing page. Building Android requires Sun JDK 5 or 6 depending on which release you are building.

  • another JDK that you previously installed appearing in your path. You can remove the offending JDK from your path with:

    $ export PATH=${PATH/\/path\/to\/jdk\/dir:/}

Python Version 3

Repo is built on particular functionality from Python 2.x and is unfortunately incompatible with Python 3. In order to use repo, please install Python 2.x:

$ apt-get install python

Gmake Version 3.82

There is a bug in make version 3.82 on Mac OS that prevents building Android.

TODO: what the error looks like with GNU make 3.82 on older builds that don't explicitly detect it.

Follow the instructions on the Initializing page for reverting GNU make from 3.82 to 3.81.

Case Insensitive Filesystem

If you are building on an HFS filesystem on Mac OS X, you may encounter an error such as

************************************************************You are building on a case-insensitive filesystem.Please move your source tree to a case-sensitive filesystem.************************************************************

Please follow the instructions on the Initializing page for creating a case-sensitive disk image.

No USB Permission

On most Linux systems, unprivileged users cannot access USB ports by default. If you see a permission denied error, follow the instructions on the Initializing page for configuring USB access.

If adb was already running and cannot connect to the device after getting those rules set up, it can be killed with adb kill-server. That will cause adb to restart with the new configuration.

Building for devices

This page complements the main page about Building with information that is specific to individual devices.

The only supported phone with the current release is the GSM/HSPA+ Galaxy Nexus, a.k.a. "maguro". GSM/HSPA+ Galaxy Nexus is currently the recommended device to use with the Android Open-Source Project.

In addition, PandaBoard a.k.a. "panda" is supported in the master branch only, but is currently considered experimental. The specific details to use a PandaBoard with the Android Open-Source Project are in the file device/ti/panda/README in the source tree.

Nexus S, a.k.a. "crespo", and Nexus S 4G, a.k.a. "crespo4g", are supported with gingerbread, but can't currently be used with newer versions of the Android Open-Source Project.

Nexus One a.k.a. "passion" is obsolete, was experimental in gingerbread and unsupported, and can't be used with newer versions of the Android Open-Source Project.

Android Developer Phones (ADP1 and ADP2, a.k.a. "dream" and "sapphire") are obsolete, were experimental and unsupported in froyo, and can't be used with newer versions of the Android Open-Source Project.

Building fastboot and adb

If you don't already have those tools, fastboot and adb can be built with the regular build system. Follow the instructions on the page about building, and replace the main make command with

$ make fastboot adb

Booting into fastboot mode

During a cold boot, the following key combinations can be used to boot into fastboot mode, which is a mode in the bootloader that can be used to flash the devices:

DeviceKeys
maguroPress and hold both Volume Up and Volume Down, then press and hold Power
crespoPress and hold Volume Up, then press and hold Power
crespo4gPress and hold Volume Up, then press and hold Power
passionPress and hold the trackball, then press Power
sapphirePress and hold Back, then press Power
dreamPress and hold Back, then press Power

Also, on devices running froyo or later where adb is enabled, the command adb reboot bootloader can be used to reboot from Android directly into the bootloader with no key combinations.

Unlocking the bootloader

It's only possible to flash a custom system if the bootloader allows it.

This is the default setup on ADP1 and ADP2.

On Nexus One, Nexus S, Nexus S 4G, and Galaxy Nexus, the bootloader is locked by default. With the device in fastboot mode, the bootloader is unlocked with

$ fastboot oem unlock

The procedure must be confirmed on-screen, and deletes the user data for privacy reasons. It only needs to be run once.

On Nexus One, the operation voids the warranty and is irreversible.

On Nexus S, Nexus S 4G, and Galaxy Nexus, the bootloader can be locked back with

$ fastboot oem lock

Obtaining proprietary binaries

Starting with IceCreamSandwich, the Android Open-Source Project can't be used from pure source code only, and requires additional hardware-related proprietary libraries to run, specifically for hardware graphics acceleration.

Official binaries for Nexus S, Nexus S 4G, Galaxy Nexus, and PandaBoard can be downloaded from Google's Nexus driver page, which add access to additional hardware capabilities with non-Open-Source code.

There are no official binaries for Nexus One, ADP2 or ADP1.

Extracting the proprietary binaries

Each set of binaries comes as a self-extracting script in a compressed archive. After uncompressing each archive, run the included self-extracting script from the root of the source tree, confirm that you agree to the terms of the enclosed license agreement, and the binaries and their matching makefiles will get installed in the vendor/ hierarchy of the source tree.

There's an additional step on Nexus S 4G. Build the signapk tool with

$ make signapk

Then reassemble the proprietary applicatons with

$ vendor/samsung/crespo4g/reassemble-apks.sh

Cleaning up when adding proprietary binaries

In order to make sure that the newly installed binaries are properly taken into account after being extracted, the existing output of any previous build needs to be deleted with

$ make clobber

Picking and building the configuration that matches a device

The steps to configure and build the Android Open-Source Project are described in the page about Building.

The recommended builds for the various devices are available through the lunch menu, accessed when running the lunch command with no arguments:

DeviceBranchBuild configuration
maguroandroid-4.0.1_r1full_maguro-userdebug
pandamasterfull_panda-eng
crespoandroid-2.3.6_r1full_crespo-userdebug
crespo4gandroid-2.3.7_r1full_crespo4g-userdebug
passionandroid-2.3.6_r1full_passion-userdebug
sapphireandroid-2.2.2_r1full_sapphire-userdebug
dreamandroid-2.2.2_r1full_dream-userdebug

Flashing a device

Set the device in fastboot mode if necessary (see above).

Because user data is typically incompatible between builds of Android, it's typically better to delete it when flashing a new system.

$ fastboot erase cache$ fastboot erase userdata

An entire Android system can be flashed in a single command: this writes the boot, recovery and system partitions together after verifying that the system being flashed is compatible with the installed bootloader and radio, and reboots the system.

$ fastboot flashall

On maguro, panda, crespo, crespo4g, sapphire and dream (but not on passion), the commands above can be replaced with a single command

$ fastboot -w flashall

Nexus S, Nexus S 4G and Galaxy Nexus Bootloader and Cell Radio compatibility

On Nexus S, Nexus S 4G, and Galaxy Nexus, each version of Android has only been thoroughly tested with on specific version of the underlying bootloader and cell radio software. However, no compatibility issues are expected when running newer systems with older bootloaders and radio images according to the following tables.

Nexus S (worldwide version "XX"):

Android VersionPreferred BootloaderPreferred RadioAlso possible
2.3 (GRH55)I9020XXJK1I9020XXJK8 
2.3.1 (GRH78)I9020XXJK1I9020XXJK8 
2.3.2 (GRH78C)I9020XXJK1I9020XXJK8 
2.3.3 (GRI40)I9020XXKA3I9020XXKB1All previous versions
2.3.4 (GRJ22)I9020XXKA3I9020XXKD1All previous versions
2.3.5 (GRJ90)I9020XXKA3I9020XXKF1All previous versions
2.3.6 (GRK39F)I9020XXKA3I9020XXKF1All previous versions

Nexus S (850MHz version "UC"):

Android VersionPreferred BootloaderPreferred RadioAlso possible
2.3.3 (GRI54)I9020XXKA3I9020UCKB2 
2.3.4 (GRJ22)I9020XXKA3I9020UCKD1All previous versions
2.3.5 (GRJ90)I9020XXKA3I9020UCKF1All previous versions
2.3.6 (GRK39C)I9020XXKA3I9020UCKF1All previous versions
2.3.6 (GRK39F)I9020XXKA3I9020UCKF1All previous versions

Nexus S (Korea version "KR"):

Android VersionPreferred BootloaderPreferred RadioAlso possible
2.3.3 (GRI54)I9020XXKA3I9020KRKB3 
2.3.4 (GRJ22)I9020XXKA3M200KRKC1All previous versions
2.3.5 (GRJ90)I9020XXKA3M200KRKC1All previous versions
2.3.6 (GRK39F)I9020XXKA3M200KRKC1All previous versions

Nexus S 4G:

Android VersionPreferred BootloaderPreferred RadioAlso possible
2.3.4 (GRJ06D)D720SPRKC5D720SPRKC9 
2.3.4 (GRJ22)D720SPRKC5D720SPRKD8All previous versions
2.3.5 (GRJ90)D720SPRKC5D720SPRKE5All previous versions
2.3.7 (GWK74)D720SPRKE1D720SPRKH1 (*)All previous versions

Galaxy Nexus (GSM/HSPA+):

Android VersionPreferred BootloaderPreferred RadioAlso possible
4.0.1 (ITL41D)PRIMEKJ10I9250XXKK1 

If you're building a new version of Android, if your Nexus S, Nexus S 4G or Galaxy Nexus has an older bootloader and radio image that is marked as being also possible in the table above but is not recognized by fastboot, you can locally delete the version-bootloader and version-baseband lines in device/samsung/crespo/board-info.txt or device/samsung/crespo4g/board-info.txt ordevice/samsung/maguro/board-info.txt

(*) As a note, radio version D720SPRKH1 for Nexus S 4G sometimes erroneously reports version D720SPRKE1. If this is the case for your Nexus S 4G, you can locally modify the version-baseband line in device/samsung/crespo4g/board-info.txt accordingly.


一. 環(huán)境準(zhǔn)備。

     1. 磁盤空間預(yù)留20G左右,內(nèi)存3G,因?yàn)橐贿呉苤鳈C(jī),一邊要跑虛擬機(jī),內(nèi)存要求還是比較高的,這樣才會(huì)比較流暢。

     2. 安裝VMWare 7.1.4。

     3. 安裝好VMWare后,接下來(lái)就安裝Ubuntu系統(tǒng)了。我選擇目前最新的版本ubuntu-11.04-alternate-i386,從網(wǎng)上查到的資料說(shuō),要編譯Android源代碼,Ubuntu的最低版本是8.04。下載好后,安裝時(shí)采用一直默認(rèn)安裝即可。

     4. 安裝Git工具。Android源代碼采用Git工具來(lái)管理,與SVN相比,這是一種分布式的源代碼管理工具,而SVN是集中式的源代碼管理工具。要安裝Git工具,在Ubuntu上執(zhí)行以下命令即可:

     USER-NAME@MACHINE-NAME:~$ sudo apt-get install git-core gnupg

     5. 安裝Java SDK。在Ubuntu上執(zhí)行以下命令:

     USER-NAME@MACHINE-NAME:~$   
sudo add-apt-repository ppa:ferramroberto/java
       
USER-NAME@MACHINE-NAME:~$ 
  
 
sudo apt-get update
     USER-NAME@MACHINE-NAME:~$   
sudo apt-get install sun-java6-jre sun-java6-plugin
     USER-NAME@MACHINE-NAME:~$   
sudo apt-get install sun-java6-jdk
   
       
   
     
     6. 依賴的其它包。在Ubuntu上執(zhí)行以下命令:
   

     USER-NAME@MACHINE-NAME:~$ sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
     7. 調(diào)試工具。在Ubuntu上執(zhí)行以下命令:
   

     USER-NAME@MACHINE-NAME:~$ sudo apt-get install valgrind
   

 二. 下載Android源代碼工程。


1.安裝git

sudo apt-get install git-core

2.安裝curl

sudo apt-get install git-core curl

3.安裝repo, 通過(guò)curl下載repo

curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo

4.給repo可執(zhí)行權(quán)限

chmod a+x ~/bin/repo

5.修改~/bin/repo文件將第五行

REPO_URL='https://code.google.com/p/git-repo/'

改為

REPO_URL='http://code.google.com/p/git-repo/'

否則會(huì)出現(xiàn)error:Failed connect to code.google.com:443; Operation now in progress while accessing https://code.google.com/p/git-repo//info/refs

6.然后向PATH中添加bin路徑:

export PATH=$PATH:~/bin

7.新建一個(gè)目錄,然后進(jìn)入該目錄。

mkdir myAndroid

cd myAndroid


8.初始化版本庫(kù)
         在源碼目錄下,初始化版本庫(kù)。
         輸入 repo init -u http://android.git.kernel.org/platform/manifest.git 將同步當(dāng)前最新的Android代碼
         輸入 repo init -u http://android.git.kernel.org/platform/manifest.git -b 版本標(biāo)識(shí) 將同步Android特定版本的源代碼分支,其中版本標(biāo)識(shí)可為 eclair,froyo,gingerbread等,分別對(duì)應(yīng)Android 2.1,2.2,2.3等版本。
         輸入以上命令后,開始進(jìn)行版本庫(kù)初始化工作,結(jié)束時(shí)可能要求配置用戶名和郵箱,隨意設(shè)置即可。
         初始化完畢后,系統(tǒng)在源碼目錄下建立 .repo 目錄,用于保存相關(guān)初始化信息。


執(zhí)行repo init -u git://Android.git.linaro.org/platform/manifest.git -b android-2.3.4_r1

這一步大概有一分多鐘就完成了。



9.找到myAndroid目錄中的.repo下面的manifest.xml文件,該文件只是一個(gè)鏈接,實(shí)際上是manifest目錄下面的default.xml文件,將

fetch="git://Android.git.kernel.org/"

改為

fetch="git://Android.git.linaro.org/"

10.執(zhí)行repo sync

         在源碼目錄下,輸入 repo sync , 即開始同步Android源代碼。
         鑒于網(wǎng)絡(luò)不穩(wěn)定帶來(lái)的隨機(jī)中斷問(wèn)題,建議使用循環(huán)指令,使在源碼同步中斷后自動(dòng)重試。在源碼目錄下新建文件 dl.sh ,該文件內(nèi)容為:
                 #!/bin/sh
                 repo sync
                 while [ $? -ne 0 ]
                 do
                     repo sync
                 done
          之后,通過(guò)輸入 ./dl.sh 即可執(zhí)行包含自動(dòng)重試機(jī)制的源碼同步過(guò)程。

  三. 編譯Android源代碼。

開始正式編譯,在源碼目錄下make即可。

make

我完全不知道跑了個(gè)啥,只知道超級(jí)卡。完成后產(chǎn)生的out文件夾有3.9G。

鏡像生成在out/target/product/generic下:android源碼編譯后得到system.img,ramdisk.img,userdata.img映像文件。其中, ramdisk.img是emulator的文件系統(tǒng),system.img包括了主要的包、庫(kù)等文件,userdata.img包括了一些用戶數(shù)據(jù),emulator加載這3個(gè)映像文件后,會(huì)把 system和 userdata分別加載到 ramdisk文件系統(tǒng)中的system和 userdata目錄下。

當(dāng)然編譯是件很痛苦的事情:

錯(cuò)誤1:

************************************************************

You are attempting to build on a 32-bit system.

Only 64-bit build environments are supported beyond froyo/2.2.

************************************************************

解決:

需要進(jìn)行如下修改即可,將

./external/clearsilver/cgi/Android.mk

./external/clearsilver/java-jni/Android.mk

./external/clearsilver/util/Android.mk

./external/clearsilver/cs/Android.mk

四個(gè)文件中的

LOCAL_CFLAGS += -m64

LOCAL_LDFLAGS += -m64

注釋掉,或者將“64”換成“32”

LOCAL_CFLAGS += -m32

LOCAL_LDFLAGS += -m32

然后,將./build/core/main.mk 中的

ifneq (64,$(findstring 64,$(build_arch)))

改為:

ifneq (i686,$(findstring i686,$(build_arch)))

錯(cuò)誤2:

host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp

frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:

frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 錯(cuò)誤 1

解決:

gedit frameworks/base/libs/utils/Android.mk

Change the line:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

To:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

錯(cuò)誤3:

host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:27: undefined reference to `pthread_getspecific'

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create'

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific'

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 錯(cuò)誤 1

解決:

打開 frameworks/base/tools/aapt/Android.mk

然后打開文件Android.mk,編輯下面一行:

ifeq ($(HOST_OS),linux)

#LOCAL_LDLIBS += -lrt       把這行注釋掉,改為下面一行。

LOCAL_LDLIBS += -lrt -lpthread

endif

錯(cuò)誤4:

target Dex: core

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

#  SIGSEGV (0xb) at pc=0x4003d848, pid=7668, tid=2889534320

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_22-b03 mixed mode)

# Problematic frame:

# C  [libpthread.so.0+0xa848]  pthread_cond_timedwait+0x168

#

# An error report file with more information is saved as hs_err_pid7668.log

#

# If you would like to submit a bug report, please visit:

#   http://java.sun.com/webapps/bugreport/crash.jsp

#

make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.dex] 已放棄 (core dumped)

解決:

虛擬機(jī)給的內(nèi)存512太小,給個(gè)1G試試。然后在本機(jī)里打開任務(wù)管理器,找到虛擬機(jī)進(jìn)程,優(yōu)先級(jí)設(shè)置為實(shí)時(shí)。給他最多東西。

錯(cuò)誤 5:

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:27: undefined reference to `pthread_getspecific'

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create'

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific'

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 錯(cuò)誤 1

解決:類似問(wèn)題3

修改./framework/base/tools/localize/Android.mk文件

ifeq ($(HOST_OS),linux)

#LOCAL_LDLIBS += -lrt       把這行注釋掉,改為下面一行。

LOCAL_LDLIBS += -lrt -lpthread

endif


錯(cuò)誤 6:Undefined reference to `__dso_handle' 
     external/stlport/src/monetary.cpp:39: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale.o: In function `__static_initialization_and_destruction_0':
     external/stlport/src/locale.cpp:29: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function `__static_initialization_and_destruction_0':
     external/stlport/src/locale_impl.cpp:31: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function `std::_Locale_impl::make_classic_locale()':
     external/stlport/src/locale_impl.cpp:670: undefined reference to `__dso_handle'
     external/stlport/src/locale_impl.cpp:667: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o:external/stlport/src/locale_impl.cpp:604: more undefined
     references to `__dso_handle' follow
     collect2: ld returned 1 exit status 
     修改external/stlport/dll_main.cpp,加入以下聲明:
     extern "C" {
            void * __dso_handle = 0;
     } 
    
 四. 編譯SDK,這一步是可選的。

執(zhí)行$sudo make PRODUCT-sdk-sdk命令,生成對(duì)應(yīng)于該版本源代碼的用于生產(chǎn)環(huán)境的sdk。

編譯的SDK版本,實(shí)際位置是./out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86。

因?yàn)樗容^常用,我們給它高優(yōu)先級(jí):

update-alternatives --install /usr/bin/AndroidSDK AndroidSDK ./out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86 255

然后使用update-alternatives --display AndroidSDK查看當(dāng)前配置情況;

如果要切換配置,使用update-alternatives --config AndroidSDK。

配置AndroidSDK環(huán)境變量。終端中執(zhí)行g(shù)edit ~/.bashrc

在文件最后添加下面三行:

# set android environment

export ANDROID_SDK_HOME=/usr/bin/AndroidSDK

export PATH=$ANDROID_SDK_HOME/tools:$PATH

保存文件。在終端中執(zhí)行source ~/.bashrc



     2. 編譯過(guò)程中可能會(huì)遇到的問(wèn)題。
     問(wèn)題一:找不到bios.bin和vgabios-cirrus.bin文件
     couldn't locate source file: usr/share/pc-bios/bios.bin
     couldn't locate source file: usr/share/pc-bios/vgabios-cirrus.bin
     注意,這里的usr/share目錄指的是~/Android/out/host/linux-x86目錄下的usr/share目錄,修改辦法是復(fù)制~/Android/prebuilt/common下的pc-bios文件夾到~/Android/out/host/linux-x86/usr/share即可:
     USER-NAME@MACHINE-NAME:~/Android$ cp ~/Android/prebuilt/common/pc-bios ~/Android/out/host/linux-x86/usr/share
    問(wèn)題二:找不到ddmlib-tests.jar、 ninepath-tests.jar 、common-tests.jar 和sdkuilib-tests.jar文件
    在~/Android/out/host/linux-x86/framework這個(gè)目錄下,可以找到以下幾個(gè)文件common.jar、ddmlib.jar、ninepatch.jar、sdkuilib.jar這四個(gè)文件,然后將它們分別復(fù)制一份,并重命名,命名的原則很簡(jiǎn)單,就是在原有的名字后面跟上-tests即可。

  五. 安裝編譯好的Android鏡像到模擬器上。
    1. 設(shè)置環(huán)境變量:
    USER-NAME@MACHINE-NAME:~/Android$ export PATH=$PATH:~/Android/out/host/linux-x86/bin  
    USER-NAME@MACHINE-NAME:~/Android$ export ANDROID_PRODUCT_OUT=~/Android/out/target/product/generic
    其中,~/Android/out/host/linux-x86/bin有我們要執(zhí)行的emulator命令,而~/Android/out/target/product/generic是Android鏡像存放目錄,下面執(zhí)行emulator命令時(shí)會(huì)用到。
    2. 運(yùn)行模擬器。
    USER-NAME@MACHINE-NAME:~/Android$ emulator
    模擬器運(yùn)行需要四個(gè)文件,分別是Linux Kernel鏡像zImage和Android鏡像文件system.img、userdata.img和ramdisk.img。執(zhí)行emulator命令時(shí),如果不帶任何參數(shù),則Linux Kernel鏡像默認(rèn)使用~/Android/prebuilt/android-arm/kernel目錄下的kernel-qemu文件,而Android鏡像文件則默認(rèn)使用ANDROID_PRODUCT_OUT目錄下的system.img、userdata.img和ramdisk.img,也就是我們剛剛編譯出來(lái)的鏡像問(wèn)題。
    當(dāng)然,我們也可以以指定的鏡像文件來(lái)運(yùn)行模擬器,即運(yùn)行emulator時(shí),即:
    USER-NAME@MACHINE-NAME:~/Android$ emulator -kernel ./prebuilt/android-arm/kernel/kernel-qemu -sysdir ./out/target/product/generic -system system.img -data userdata.img -ramdisk ramdisk.img
    到這里,我們就可以在模擬器上運(yùn)行我們自己編譯的Android鏡像文件了,是不是很酷呢?但是注意,這里說(shuō)的Android鏡像文件,只是包括system.img、userdata.img和ramdisk.img這三個(gè)文件,而Linux Kernel鏡像用的是Android為我們預(yù)編譯好的kernel-qemu鏡像。那么,有沒有辦法使用我們自己編譯的Linux Kernel鏡像呢?答案上肯定的,這樣我們就可以完全DIY自己的Android系統(tǒng)了


本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
android 編譯SDK 問(wèn)題匯總
Ubuntu10.04上編譯Android源碼(Build Android source in Ubuntu10.04 Platform)
【搬運(yùn)】TF101啟動(dòng)多系統(tǒng)
ubuntu 11.04 安裝jdk
android模擬器創(chuàng)建和使用SD卡
Android fastboot 模式升級(jí) (包括 Windows xp 和 Ubuntu 10.04 下)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服