分享

Howto Build Android 4.3 for Nexus 4

 joy_chen 2013-11-08
October 9, 2013

This post will walk through building and deploying Android 4.3 (Jelly Bean MR2) for a Nexus 4 device, from upstream sources.

Overview

A useful source tree, in practical terms, requires these components:

  1. Proprietary binaries for hardware support
  2. Proprietary Google Apps applications (e.g. Play store)
  3. The AOSP system image, recovery image, modem firmware, etc.
  4. A kernel

These four components are not bundled together, and need to be assembled into the Android build system.

Obtain the AOSP source

First, obtain the AOSP tree:

1
2
repo init -u https://android./platform/manifest -b android-4.3_r1.1
repo sync -c -d -j10

Get the proprietary hardware support files

Now, get the proprietary hardware support files, and install them to the source tree:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
cd $ANDROID_BUILD_TOP
 
wget https://dl.google.com/dl/android/aosp/broadcom-mako-jwr66y-137ef66d.tgz
wget https://dl.google.com/dl/android/aosp/lge-mako-jwr66y-a85ca75e.tgz
wget https://dl.google.com/dl/android/aosp/qcom-mako-jwr66y-a5becaf1.tgz
 
for item in *.tgz; do
    tar xzvf $item
done
 
for item in *.sh; do
    bash $item
done
 
# Manually accept all agreements to expand files into ./vendor tree.
 
rm *.sh *.tgz

Note: probably a good idea to stash these in a/some git repository/ies.

Setup the kernel

Now, get the kernel. Note that the version in the android-msm-mako-3.4-jb-mr2 branch actually has a display driver bug, and “tears” during scroll, out of box. The solution is to use the same revision as is in the stock kernel image.

1
2
git clone https://android./kernel/msm kernel
git checkout f43c3d9dd98e351a98bbcccff5933061493f30a4

Alright — but it turns out that the AndroidKernel.mk, the main Makefile for the Android kernel, has some issues. The kernel config has modules disabled, but the makefile tries to build modules. You can comment out the offending lines with this sed command:

1
sed -i '/\t\+\$(.*module/s/^/#/' kernel/AndroidKernel.mk

Get the proprietary Google Apps

There are a couple ways to go about this, but an easy way is to download the proprietary files in a bundle from RootzWiki:

1
wget http://goo.im/gapps/gapps-jb-20130813-signed.zip

That package is intended to be use as an update.zip through a recovery session, once the phone is all loaded with an image. An alternative is to create Makefiles so that the files get included in the build. The key files are device-partial.mk, and Android.mk.

You can also cheat and just checkout that project, into your tree:

1
2
3
cd $ANDROID_BUILD_TOP
mkdir -p vendor/google
git clone https://github.com/jamesonwilliams/vendor_google_mako vendor/google/mako

A few modifications, to include the the added files

We now have all of the basic components we need to build, but still have to make a few tweaks to the build system. Firstly, we want to use the files we downloaded to ./vendor, so have to remove the RODUCT_RESTRICT_VENDOR_FILES directive:

1
sed -i '/PRODUCT_RESTRICT_VENDOR_FILES/s/^/#/' device/lge/mako/full_mako.mk

Similarly, we want to use the kernel source we added to the tree — not the prebuilt kernel image that comes with AOSP. The changes to support this can be viewed in this commit.

Lastly, we need to add a couple of lines so that the Google Apps files are included in the build. Changes to support this can be found in this commit.

Build the Thing

Alright. Assuming all of the above was followed carefully, we should be ready to build:

1
2
3
4
5
cd $ANDROID_BUILD_TOP
. build/envsetup.sh
lunch full_mako-user
make clean
make updatepackage

The update package ends up at $OUT/$TARGET_PRODUCT-img-$TARGET_BUILD_VARIANT.$USER.zip.

Deploy the Thing

Plug in your Nexus 4, ensure that you are able to do USB Debugging, and run:

1
2
3
adb reboot-bootloader
fastboot oem unlock
fastboot -w update $OUT/$TARGET_PRODUCT-img-$TARGET_BUILD_VARIANT.$USER.zip

At that point, the phone will reboot, and you’ll be running Android 4.3 on your Nexus 4.

http:///build-android-4-3-nexus-4

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多