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. OverviewA useful source tree, in practical terms, requires these components:
These four components are not bundled together, and need to be assembled into the Android build system. Obtain the AOSP sourceFirst, obtain the AOSP tree:
Get the proprietary hardware support filesNow, get the proprietary hardware support files, and install them to the source tree:
Note: probably a good idea to stash these in a/some git repository/ies. Setup the kernelNow, 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.
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:
Get the proprietary Google AppsThere are a couple ways to go about this, but an easy way is to download the proprietary files in a bundle from RootzWiki:
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:
A few modifications, to include the the added filesWe 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:
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 ThingAlright. Assuming all of the above was followed carefully, we should be ready to build:
The update package ends up at Deploy the ThingPlug in your Nexus 4, ensure that you are able to do USB Debugging, and run:
At that point, the phone will reboot, and you’ll be running Android 4.3 on your Nexus 4. |
|