Android extended series (6)-cm9 source code download and compilation

Source: Internet
Author: User

Recently, the company began to modify the framework based on android4.0 ICs. The company's mobile phone is not suitable for home testing and does not have the kernel permission.
From a personal perspective, I have two mobile phones, one is HTC G9 Aria and the other is Samsung i9100 galaxys2 and cyanogenmod.Source codeAll provide driver support for these mobile phones, and can be easily compiled and packaged, and installed on mobile phones.
PreviousArticleIt is the compilation of android2.3, it is outdated, and now Ubuntu has been upgraded to 12.04, and so on, I think it is very necessary to write a new blog to show how the latest Android is compiled on the latest ubuntu.
Based on the above points, I will demonstrate how to compile the cm9 source code based on galaxys2 and package and zip it to your mobile phone. The following is my reference article:
Http://source.android.com/source/initializing.html
Http://forum.xda-developers.com/showthread.php? T = 1552090
Https://github.com/CyanogenMod/android
These links have more or less problems. From these things, I have sorted out the simplest and most effective way to compile. Maybe the steps in these articles are inconsistent with those mentioned above.

1. Select ubuntu12.04
I used x64 for the first time and found many errors when configuring the environment. Later I used a 32-bit system and installed these necessary software without any errors, so here, if cyanogenmod ICS source code is compiled using the 12.04 system, I recommend using a 32-bit system with my personal experience.

2. Memory and CPU
Some of my friends installed Ubuntu on the virtual machine, so the memory allocation may be too small. We recommend that you try to increase the size as much as possible. During my 1 GB memory, I encountered an error during compilation, restart to set 2 GB memory.
If the CPU is too weak, the process may be killed during the compilation process. I used it once and restarted it. So pay attention to the CPU level.

3. java selection
no matter the official Android document or the article above, the installation of Java will not be found, and their software source has problems. Manual installation is required.
but Android ICS compilation, the official article pointed out that support openjdk-6-jdk, so you can directly install openjdk6.
Note: Here I want to explain that the compilation script of cm9 ignores or handles some possible errors compared with the compilation script of the official source code, for example, if the Java version is tested here, the official compilation will fail if it is open JDK. In fact, it is the same. You only need to modify the script (build/CORE/main. mk), locate the Java version:

# Check for the correct version of javajava_version: =$ (shell Java-Version 2> & 1 | head-N 1 | grep '^ Java. * ["] 1 \. 6 [\. "$] ') ifneq ($ (shell Java-Version 2> & 1 | grep-I openjdk),) java_version: = endistmeq ($ (Strip $ (java_version )),) $ (Info ************************************* ***********************) $ (info you are attempting to build 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 $ (Space) http://source.android.com/source/download.html) $ (Info ************************************* ***********************) # $ (error stop) // if you are sure that JDK has been installed correctly, remove this sentence to endif

The compilation script of cm9 directly removes this sentence, but you should pay attention to installing the correct JDK version.

4. fixed the problem that Google source could not be accessed during the download process.
You need a VPN account.
The vpn I purchased earlier also has a free VPN. For details about the free VPN and VPN configuration, refer to the following two links:
Http: // 173.252.215.172/Server/Query
Http: // 173.252.215.172/setting/ubuntu.shtml
After configuring VPN, We can smoothly download all the cm9 source code from ubuntu.

5. Environment Configuration
Refer to the official Ubuntu 12.04 (please note the official documentation to distinguish ubutu11.10 X6 from the previous system). We need to configure the following environment:

 
Sudo apt-Get install Git-core GnuPG flex bison gperf build-essential tialsudo apt-Get install zip curl libc6-dev libncurses5-dev: i386 x11proto-core-devsudo apt-Get install libx11-dev: i386 libreadline6-dev: i386 libgl1-mesa-dev: i386sudo apt-Get install g ++-multilib mingw32 openjdk-6-jdk tofrodos Python-markdownsudo apt-Get install libxml2-utils unzip tproc zlib1g-dev: i386

There should be no problems.

6. Install Repo

Cdmkdir bincurl https://dl-ssl.google.com/dl/googlesource/git-repo/repo> ~ /Bin/repochmod A + x ~ /Bin/repoalias repo = "~ /Bin/repo"

If we need to run the repo at any time, we 'd better configure the repo in the environment:

 
Vim ~ /. Bashrc # Add alias repo = "~ /Bin/repo ", save and exit source ~ /. Bashrc

In this user environment, you can repo wherever you are.

7. Download The cm9 source code
List Files are hosted on GitHub: https://github.com/CyanogenMod/android

 
Mkdir cm9cd cm9repo init-u git: // github.com/cyanogenmod/android.git-B icsrepo sync

The ICS branch is the branch of cm9 ICs.
Wait for a while (if you are not prompted to open googlesource during the download process, remember to refer to the previous configuration of VPN firewall, I changed the host is invalid ).

8. Configure USB
This step is to copy the system property file from your mobile phone and compile the source code.
Ubuntu do not need to install a driver to connect to your phone, but need to configure, can refer to the official: http://source.android.com/source/initializing.html
Here I will also write down:

Sudo Vim/etc/udev/rules. d/51-android.rules

Then, add the following content:

 
# Samsungsubsystem = "USB", sysfs {idvendor }== 04e8, mode = 0666

This is the configuration of a Samsung mobile phone. Other mobile phones use the lsusb command to view the corresponding ID./Etc/udev/rules. d/51-android.rules file.
After the configuration, unplug the phone and plug it in. Basically, you can. If not, kill the-server first and connect it with the root user. If the problem persists, go to Android-SDK/tools/and give your ADB command file "chmod + s adb", kill-server, and ADB. Try again several times.

9. Download a dedicated project for the device
Cm9 is different from cm7 in downloading the device project. cm7 is automatically downloaded when the source code is downloaded. cm9 does not exist, but it can be manually intelligently recognized for downloading.
For example, if my mobile phone is galaxys2, run the following command:

 
Brunch galaxys2

If the spelling is correct, it will automatically download the related projects of galaxys2 (in the directory ~ The following directory Samsung/galaxys2 is added to/cm9/device ).

If the download is complete, stop compiling and proceed to the next step.

10. Get the mobile phone system property File

Cd ~ /Cm9/device/Samsung/galaxys2./extract-files.shcd ~ /Cm9vendor/CM/get-prebuilts

This step only needs to be executed once.

11. Compile the cm9 source code
The source code of cm9 is much less error-prone than compiling the official Android source code.
First, initialize the variable:

 
CD cm9source build/envsetup. Sh

Run the following command:

 
Brunch galaxys2

Then wait!
If it is a virtual machine, the memory is tight and the CPU is insufficient, errors may occur at any time.
If an error occurs, analyze the cause of the error. It is still quite smooth here, interrupted once, and re-compiled again.
PS: For official source code compilation, I believe there are always several errors, and cm9 is much better.
After compilation is complete, a zip file is generated, which can be flushed on your mobile phone.

12. compile the project
So far, we have set up a healthy cm9 environment, but our goal is not to compile the cm9 Rom, and this CM will generate a version of "nightly" every day, therefore, we mainly use this cm9 environment to compile frameworks, apps, and other projects.
For example, if we restart the system the next day, how does one compile framework-res.apk, framework.jar, and music.apk? We need to use this environment:

CD cm9source build/envsetup. sh // note the product name. When chooseproduct is used, add cM _ to galaxys2 _, otherwise, the product chooseproduct cm_galaxys2 // is not found. Go to framework/base/CORE/res.compile framework-res.apk CD framework/base/CORE/resmm // or compile the framework. jarcd ~ /Cm9/framework/base/CORE/javamm // You can compile music.apk Cd ~ /Cm9/packages/apps/musicmm

In this way, you can modify the system ROM and the system app.

13. Summary
Building an android environment and compiling the android source code is a complex, time-consuming, and time-consuming process.
However, it is actually very easy to look back.

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.