Android notes: CM9 source download and compiler application _android

Source: Internet
Author: User
Tags chmod curl mkdir java se

The company has also recently started to modify the framework based on Android4.0 ICS, the company's mobile phone is temporarily not suitable for home testing, there is no kernel permissions.
Personally, I have two mobile phones, one is HTC G9 Aria, a Samsung I9100 galaxys2,cyanogenmod open Source code that provides the driver support for these phones, and can be easily compiled and packaged, and installed to the mobile phone.
The previous article was compiled by android2.3, outdated, and now that Ubuntu has been upgraded to 12.04, and so on, makes it very necessary for me to write a new blog to show how the latest Android can be compiled on the latest Ubuntu.
Based on the above points, I will show you how to compile the Cm9 source code and package zip to the phone based on Galaxys2.

The choice of 1.ubuntu12.04
I first use x64 system, found that the configuration of the environment, there will be many kinds of errors, and then I use 32-bit system, install these prerequisite software is nothing wrong, so here, if the 12.04 system compiled CyanogenMod ICS source code, I recommend using 32-bit systems as a personal experience.

2. Memory and CPU
Because some friends install Ubuntu on the virtual machine, so the memory allocation may be easy to small, recommended as large as possible, I 1G memory, the compilation of errors, reset 2G memory is no problem.
CPU is too weak, the process of compiling is also easy to kill, I appeared once, restart after OK. So the CPU level should pay attention to.

3.java of choice
Whether it is the official Android document or the article above, Java installation will not be found, their software source is problematic. Manual installation is required.
However, the compilation of Android ICS, the official article pointed out that support OPENJDK-6-JDK, so you can install openjdk6 directly.
Note: Here I would like to explain CM9 's compilation script ignores or deals with some of the possible errors, such as the Java version of the test, if it is an open JDK, but the official compiles the same, and only needs to modify the script ( BUILD/CORE/MAIN.MK), find a place to detect the Java version:

Copy code code as follows:

# Check for the correct version of Java
Java_version: = $ (Shell java-version 2>&1 | head-n 1 | grep ' ^java. *["]1\.6[\.") $$]')
IFNEQ ($ (Shell java-version 2>&1 | grep-i openjdk),)
Java_version: =
endif
Ifeq ($ (Strip $ (java_version)),)
$ (Info ************************************************************)
$ (info for are attempting to builds with the incorrect version)
$ (Info of java.)
$ (Info $ (space))
$ (Info Your version is: $ (shell java-version 2>&1 | head-n 1).)
$ (Info the correct version Is:java SE 1.6.)
$ (Info $ (space))
$ (Info please follow the machine setup instructions at)
$ (Info $ (spaces) $ (space) $ (spaces) $ (space) http://source.android.com/source/download.html)
$ (Info ************************************************************)
#$ (Error stop)//If you are sure that the correct JDK is installed, remove this sentence and let the compilation continue
endif

CM9 's compilation script simply removes this sentence, but be careful to install the correct JDK version.

4. Solve the problem that googlesource can't access during the download process
You need a VPN account to flip the wall.
This I used before I purchased a VPN, there are free VPN, specific free VPN and VPN configuration, you can refer to the following two links:
Http://173.252.215.172/server/query
Http://173.252.215.172/setting/ubuntu.shtml
Configured VPN, our Ubuntu will be able to smoothly download all the CM9 source code.

5. Environment configuration
Referring to the official Ubuntu 12.04 (Please note the official documentation, distinguishing between Ubutu11.10 X6 and previous systems), we need to configure the following environments:

Copy Code code as follows:

sudo apt-get install Git-core GnuPG Flex Bison gperf build-essential
sudo apt-get install zip curl Libc6-dev libncurses5-dev:i386 X11proto-core-dev
sudo apt-get install libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386
sudo apt-get install g++-multilib mingw32 openjdk-6-jdk Tofrodos
sudo apt-get install libxml2-utils xsltproc zlib1g-dev:i386

There should be nothing wrong with that.

6. Install Repo

Copy Code code as follows:

Cd
MkDir bin
Curl Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
Alias repo= "~/bin/repo"

This can be, but we need to be able to run repo at any time, it is best to configure the repo to the environment:
Copy Code code as follows:

Vim ~/.BASHRC
#打开后, add the alias repo= "~/bin/repo" at the end of the file, and then save the exit
SOURCE ~/.BASHRC

The next time the user environment will be able to repo whenever and wherever.

7. Download CM9 Source
The list file is hosted on the GitHub: https://github.com/CyanogenMod/android

Copy Code code as follows:

mkdir CM9
CD CM9
Repo Init-u git://github.com/cyanogenmod/android.git-b ICS
Repo Sync

The ICS branch is the branch of CM9 ICS.
Slowly wait for it (if the download process, Non-stop prompts to open googlesource words, remember to refer to the previous configuration VPN over the wall, I changed the host invalid).

8. Configure USB
This step is to the back from your phone copy system Properties file, the user compiled source code.
Ubuntu does not need to install drivers to connect to your mobile phone, but need to configure, can refer to the official: http://source.android.com/source/initializing.html
I also simply write down here:

Copy Code code as follows:

sudo vim/etc/udev/rules.d/51-android.rules

Then, add the following:
Copy Code code as follows:

#Samsung
subsystem== "USB", Sysfs{idvendor}==04e8, mode=0666

This is the configuration of Samsung mobile phones, other mobile phones through the LSUSB command to see the corresponding ID, in the above format to add to the/etc/udev/rules.d/51-android.rules file.
Once configured, unplug the phone and plug it in, and basically it's OK. If not, first kill-server, then the root user connection. If not, enter android-sdk/tools/, give your adb this command file "chmod +s adb", kill-server, then ADB, try a few more.

9. Download Equipment Special Project
CM9 now and CM7 in the download Equipment project is not the same, CM7 download the source code when the automatic download is good, CM9 is not, but can manually intelligent identification download.
For example, if my cell phone is GALAXYS2, use the following command:

Copy Code code as follows:

Brunch GALAXYS2

If spelled correctly, it automatically downloads GALAXYS2 related works (~/cm9/device/the following directory Samsung/galaxys2 under the directory).

If the download completes, go to compile, please stop compiling, we also need to proceed to the next step.

10. Get cell Phone System Properties file

Copy Code code as follows:

CD ~/CM9/DEVICE/SAMSUNG/GALAXYS2
./extract-files.sh
CD ~/CM9
Vendor/cm/get-prebuilts

This step can only be done once.

11. Compile CM9 Source code
CM9 's source code is much less prone to error than compiling the official Android source code.
First, initialize the variable:

Copy Code code as follows:

CD CM9
SOURCE build/envsetup.sh

Direct use of the command:
Copy Code code as follows:

Brunch GALAXYS2

Then slowly wait for it!
If it is a virtual machine, the memory is tight and the CPU is low, you can error at any time.
If there is a mistake, pay attention to analyze the cause of the error, I am still relatively smooth, interrupted once, recompile again can be.
PS: If the official source code compiled, I believe there are a number of mistakes, CM9 better.
When the compilation is complete, a zip file is generated, which can be brushed on the phone.

12. Compiling engineering
Up to now, we have built a healthy CM9 environment, but our goal is not to compile CM9 ROM, this cm will be nightly version every day, so we mainly use this CM9 environment to compile framework,app and other works.
Like the next day we reboot, how to compile framework-res.apk,framework.jar,music.apk? We need to use this environment:

Copy Code code as follows:

CD CM9
SOURCE build/envsetup.sh
Attention to Product name, Chooseproduct, before galaxys2 to add cm_, or can not find the product
Chooseproduct Cm_galaxys2
Below into the framework/base/core/res. Compiling framework-res.apk
CD Framework/base/core/res
Mm
You can also compile Framework.jar
CD ~/cm9/framework/base/core/java
Mm
You can also compile music.apk
CD ~/cm9/packages/apps/music
Mm

This allows you to modify the system ROM and modify the system app.

13. Summary
Building the Android environment and compiling the Android source code is a complex, time-consuming, late-night process that is not easy.
But, in fact, it is very simple to look back.

Related Article

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.