Download and compile Android source code under Arch Linux

Source: Internet
Author: User
Tags virtual environment arch linux

Previously, the company's development environment was replaced by the Ubuntu Kylin with Arch Linux. and arch under the various problems of the company's code has been compiled just to go. After the fix has also been forgotten to write down, hoping to give the same under the Arch of Android Development of an alternative to help it. The Android version number compiled here is based on Google's Android 5.1.

Install basic dependencies

First /etc/pacman.conf Open your multilib in a file repo

[multilib]Include = /etc/pacman.d/mirrorlist

Then force an update on the local repo

sudo pacman -Syy

Then install the dependencies required for compilation

sudo pacman- SBase-develBC Curl git gnupg gperf jdk7-OPENJDKLib32-expatLib32-GCC-libsLib32-glib2Lib32-GLIBCLib32-GLIBCLib32-libdbusLib32-libffiLib32-libpngLib32-ncursesLib32-pcreLib32-readlineLib32-zliblibpng libxml2 libxslt ncurses perl-switchReadLine Schedtool SDL SQUASHFS-toolsUnzip WXGTK zip zlib

Also you need to manually set up a few soft connections

/usr/lib/libtinfo.so -> /usr/lib/libncursesw.so/usr/lib/libtinfo.so.5 -> /usr/lib/libncursesw.so/usr/lib/libtinfo.so.6 -> /usr/lib/libncursesw.so/usr/lib/libncurses.so.5 -> /usr/lib/libncursesw.so/usr/lib/libncurses.so.6 -> /usr/lib/libncursesw.so
Python2 Virtual Environments

Because Google repo scripts need to Python2 the environment. Python3 is used by default in arch Linux, so you need to be able to switch to the PYTHON2 environment in a non-global way. This can be done by package Python-virtualenvwrapper .
Install this package first

-S python-virtualenvwrapper

Since Google's envsetup.sh script has to be interpreted by bash, you need to switch to bash beforehand, assuming that you don't need to switch by default with bash. Maybe we can test the effect of using zsh.

bash

Then create a python2 virtual environment where the first two rows of setting environment variables are best written to your shell configuration file

export WORKON_HOME=~/.virtualenvsexport VIRTUALENVWRAPPER_PYTHON=$(which python3)source /usr/bin/virtualenvwrapper.shmkvirtualenv -p $(which python2) python2

We then entered the Python2 virtual environment. It is important to note that python-virtualenvwrapper can create python2 virtual environments, but must rely on python3 talent to run. Assuming you want to switch to the PYTHON2 environment later, you just need to run the built-in source instructions and functions to ensure that the environment variables are correct workon .


Finally, don't forget to empty the lc_all environment variable for the lc* variable to take effect. Or repo it will be broken without mercy.

export LC_ALL=‘‘

In the Python2 virtual environment that you created. Now Google's repo scripts should be able to run correctly and be able to synchronize the code locally.


Assuming you're repo still crashing, you're probably using it before you move the development environment to Arch repo , assuming this is the case then run the following statement and start your Sync operation again

rm ~/.repopickle_.gitconfig
An error rule

A very deceptive place is that Google wrote a makefile rule a long time ago.

In late August, I got the source code for the Android M preview, but found that this error rule still exists.

On the low version of the GNU make, this rule is covered by other rules, the code can be compiled smoothly, but due to the rolling upgrade feature of Arch Linux, the high version of the GNU make has been able to correctly use the wrong rule. Causes a compile break. You need chipram/Makefile to change the method, such as the following

Diff--git A/makefile B/makefileindex3017572..A32df100644---a/makefile+++ b/makefile@@- the,7+ the,7 @@ $(Splobjdir)%.O:$(Srctree)/nand_spl/%.C$(CC)$(CFLAGS)-mlittle-endian-dconfig_nand_spl-c-O[email protected] $< $(Splobjdir)%.O:$(Srctree)/nand_spl/board/$(VENDOR)/$(SOC)/%.S-$(CC)$(CFLAGS)-mlittle-endian-dconfig_nand_spl-c-O[email protected] $<+$(CC)$(aflags)-mlittle-endian-dconfig_nand_spl-c-O[email protected] $< $(Splobjdir)%.O:$(Srctree)/arch/$(ARCH)/lib/%.S$(CC)$(aflags)-mlittle-endian-dconfig_nand_spl-c-O[email protected] $<
Compilation of code

Before you run the compilation, you need to set the Lc_all again to overwrite the lc* variable, otherwise the compilation won't be long before you start a somersault.

export LC_ALL=C

And then it's the standard procedure for compiling Android code.

./build/envsetup.shlunchmake update-api-j8
High-speed Setup function

Finally, we provide a function to switch to the Android compilation environment at high speed android_env , and another function to match it repo . Write this two function into your shell configuration file (such as ~/.ZSHRC) and you can then use the command

android_env

Switch to the compilation environment at high speed. Suitable for users with the default shell of Zsh. These two functions can be obtained here.

Other assorted problem is the company self-research part of the problem, including makefile Write Wrong flag (compilation) and other defects, it is not written here.
By the way, using arch as a development environment is not inconvenient, the rolling upgrade means that the tool chain can be kept up to date, the high level of development also determines the system into a lightweight development environment, the same time excellent package management mechanism is also very worry, compared with Ubuntu is an advantage.


Download and compile Android source code under Arch Linux

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.