Ubuntu Android source and kernel download and compile _android

Source: Internet
Author: User
Tags curl gnupg git clone gc overhead limit exceeded

This tutorial is based on Ubuntu under the Android6.0.1 source and the kernel download and compile, record, and then do not have to find their own data, over and over again to try. Can turn over the wall, English is good, go straight to Androidsource.

System Environment: Ubuntu14.04lts

Android version: 6.0.1

Important Web site

Tsinghua University Mirror Image
Androidsource

Pre-Download preparation

Install OpenJDK

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
sudo Update-alternatives--config java
java-version

Install Git

sudo apt-get install Git-core

Install an additional build

sudo apt-get install GnuPG flex Bison gperf build-essential \ Zip Curl zlib1g-dev gcc-multilib g++-multilib
 i386 \
 Lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
 Libgl1-mesa-dev libxml2-utils Xsltproc Unzip

Build function Introduction Web Site
GnuPG Encryption tool GPG Introductory Tutorials
Flex The Fast lexical Analyzer Quick Syntax Analysis tools
Bison For automatic generation of parser programs Automatic generation of parser programs
Gperf The perfect hash function generator Use Gperf to implement efficient C + + command line processing
Build-essential Compilation of make Menuconfig into graphics in the kernel Build-essential
Zip Compression and decompression of Zip package under Linux Compression and decompression of Zip package under Linux
Curl Network request and extraction tools Curl Website Development Guide
Zlib1g-dev Tools for discovering Gzip and PKZIP Binary package "Zlib1g-dev" in Ubuntu trusty
Gcc-multilib Allows 32-bit applications to be run in 64-bit machines Multilib
G++-multilib Ibid. (g++ Compilation tool) Multi-platform Support
Libc6-dev-i386 Embedded GNU C library:32-bit development libraries for AMD64 Libc6-dev-i386
Lib32ncurses5-dev To be perfected To be perfected
X11proto-core-dev To be perfected To be perfected
Libx11-dev To be perfected To be perfected
Lib32z-dev To be perfected To be perfected
CCache To be perfected To be perfected
Libgl1-mesa-dev To be perfected To be perfected
Libxml2-utils To be perfected To be perfected
Xsltproc To be perfected To be perfected
Unzip To be perfected To be perfected

Download

Because of the network and the reasons for the wall, we use Tsinghua University mirroring, the following steps:

Download the Repo tool

mkdir ~/bin
path=~/bin: $PATH
Curl Https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Download source

wget Https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # Download Initialization package
Tar XF Aosp-latest.tar
CD AOSP # extract AOSP Engineering directory
# at this time LS words can see nothing, because there is only one hidden. Repo Directory
Repo Sync # Normal sync to get the full catalog
# or repo sync-l only checkout code

PS: Total 25G, slow down!

Compile

Enter the AOSP root directory

Initializing the compilation environment

. build/envsetup.sh

Select compilation target, select 1, all options mean, back to update

Lunch

Start compilation, where 4 concurrent numbers are used:

Make-j4

Using the packaging tool mmm, after completing the command, you will generate ANDROID.IRP in the root directory, open an existing project with Android Studio, and open Android.irp

Mmm development/tools/idegen/

Running the current version of the emulator

Add the emulator source directory to the path

Export Path=&path:~/bin/aosp/out/host/linux-x86/bin

Set source code compile output directory

Export Android_product_out=~/bin/aosp/out/target/product/generic

Run emulator

Emulator

Download the Android kernel source code

Go to the kernel directory and download the kernel

git clone https://aosp.tuna.tsinghua.edu.cn/android/kernel/goldfish.git

Enter Goldfish directory, select Branch

CD Goldfish
Git branch-a
git checkout remotes/origin/android-goldfish-2.6.29

Compiling the Android kernel source code

To add the cross-compilation tool directory to the PATH environment variable

Export path= $PATH: ~/bin/aosp/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin

Open Goldfish Makefile Modify the configuration file, locate the Arch,cross_compile, and modify it as follows

ARCH =arm.
Cross_compile? =/home/user/bin/aosp/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/
arm-linux-androidkernel-

Note: Be sure to set the absolute path.

Build configuration file and compile

Make Goldfish_defconfig
Make

Run the current kernel version of the emulator

Running the current emulator

Emulator-kernel./kernel/goldfish/arch/arm/boot/zimage

View Kernel version

ADB shell
CD proc
Cat version

Bugs

JDK Memory Overflow

FAILED:/bin/bash OUT/TARGET/COMMON/OBJ/JAVA_LIBRARIES/FRAMEWORK_INTERMEDIATES/DEX-DIR/CLASSES.DEX.RSP
Out of Memory error (version 1.2-RC4 ' Carnac ') (298900 f95d7bdecfceb327f9d201a1348397ed8a843843 by android-jack-team@google.com)).
GC overhead limit exceeded.
Try increasing heap size with Java option '-xmx<size> '.
Warning:this may have produced partial or corrupted output.
Ninja:build Stopped:subcommand failed.
Make: * * * * [Ninja_wrapper] Error 1

A:

Export jack_server_vm_arguments= "-dfile.encoding=utf-8-xx:+tieredcompilation-xmx4g"
./prebuilts/sdk/tools/jack-admin Kill-server
./prebuilts/sdk/tools/jack-admin Start-server

The above is on the Android source download, and compile, follow-up continue to update the relevant articles, thank you for your support of this site!

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.