Build Ubuntu Android environment and execute shell scripts

Source: Internet
Author: User
Tags gnupg

 

1. Enter the Ubuntu system and set up the android development environment.

1. Update the software source before installing the new system. In this way, when we use some software, we can directly use the tab key to complete the name of the software package to be installed, and then install it.

 

Sudo apt-Get update

 

2. install some necessary software for Android Development

 

Sudo apt-Get install GnuPG flex bison gperf build-essential zip curl zlib1g-dev gcc-4.1-multilib libc6-dev-i386 g ++-4.1-multilib lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

Some software functions:

GnuPG (GNU Privacy Guard or GPG) is an open source code software released under the GNU General Public License for encryption or signature.

Flex and bison are both lexical analyzer generators. They are often used together to generate interpreters, compilers, protocol implementations, and other programs.

Zip is a File compression format. This software is generally used to compress ZIP files.

GCC and G ++ are C and C ++ compilers in Linux.

The rest are necessary libraries.

 

3. Make/bin/sh only want bash

Generally, after installing the system, the default SH is directed to dash. Dash is also a shell script, but it is outdated. Now, basically all shell scripts use the bash parser, so we just want sh to be Bash

 

Sudo RM/bin/sh

Sudo ln-S/bin/bash/bin/sh

Ls/bin/sh-L. You can see that sh has been directed to bash.

 

4. Change the GCC and G ++ versions because the android environment requires a specific GCC and G ++ compiler.

 

CD/usr/bin/

Ls-La | grep gcc

Sudo ln-s x86_64-linux-gnu-gcc-4.1 x86_64-linux-gnu-gcc

Sudo RM gcc

Sudo ln-s gcc-4.1 gcc

 

Ls-La | grep g ++

Sudo Rm-RF./g ++

Sudo Rm-RF x86_64-linux-gnu-g ++

Sudo ln-s x86_64-linux-gnu-g ++-4.1 x86_64-linux-gnu-g ++

Sudo ln-s g ++-4.1./g ++

 

GCC -- version

G ++ -- version to check whether GCC and G ++ are the required version 4.1.3.

 

5. Installation of the Cross-compiler Arm GCC and jdk1.5

Because we want to run the android program, the Board adopts the ARM architecture and the processor is arm, so we need arm GCC.

JDK is the core of Java, including the Java Runtime Environment, Java tools, and Java-based class libraries. Java is the main programming language on the top of the Android system, so it is very important.

 

Sudo tar xzvf prebuilt-0f1763c.tar.gz-C/OPT

Sudo mV/opt/prebuilt-0f1763c // opt/arm-eabi-4.4.0/

Sudo jdk-1_5_0_22-linux-amd64.bin/opt/

CD/OPT

Sudo chmod A + x jdk-1_5_0_22-linux-amd64.bin

Sudo./jdk-1_5_0_22-linux-amd64.bin

 

6. Install wine1.2

Wine is an excellent linu system simulator software. It runs software in a Linux system stably and runs many software in a large windows system.

 

Sudo apt-Get install wine1.2

 

7. Create the android compiling environment configuration script

Sudo Vim/etc/Android. conf

Copy the following statement to Android. conf.

# Android Profile

 

Java_home =/opt/jdk1.5.0 _ 22"

Export java_home

 

Android_java_home =/opt/jdk1.5.0 _ 22

Export android_java_home

 

Path =/opt/arm-eabi-4.4.0/bin:/opt/jdk1.5.0 _ 22/bin:/opt/android_sdk_2.1/tools:/opt/wine-1.1.33/bin: $ path

Export path

 

When we compile the Android software, we need to execute

Source/etc/Android. conf

 

After all the above work is completed, we will build the android development environment.

PS: For how to build the android environment, I also wrote a shell script to integrate all the operations into the script and test the operation. We only need to./execute the script to complete all the work, which is very convenient. O (objective _ objective) O hopes to help you.

 

I personally think: When we often do some projects, we can describe some of the tedious and error-prone execution processes with one script. We only need to parse the script, we can complete the previous tedious steps, which are easy to use and save time. For example, during kernel compilation, makefile must be used to describe the compilation process. scripts such as makefile and shell exist to simplify complicated operations and improve project execution efficiency.

 

2. The shell script is as follows,You just need to copy the script content to any empty file you create such as a android-build.sh, execute the CHMOD + x android-build.sh, and then the./android-build.sh will automatically install. Put the Plugin in the $ home directory of ubuntu (that is, the subdirectory you created under the default terminal directory). Here I create the android_build directory.

 

#! /Bin/sh

 

######################################## #########

# The Program is to build Android's environment #

######################################## #########

############################

# Version 1.0 by jian. Kong #

############################

 

 

##### 1. Install the required software ######

Sudo apt-Get install GnuPG flex bison gperf build-essential zip curl zlib1g-dev gcc-4.1-multilib libc6-dev-i386 g ++-4.1-multilib lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

 

##### 2. Make shell point to bash ######

Sudo RM/bin/sh

Sudo ln-S/bin/bash/bin/sh

 

##### 3. Change the GCC from version 4.4.1 to version 4.1.3 #########

CD/usr/bin/

Ls-La | grep gcc

Sudo ln-s x86_64-linux-gnu-gcc-4.1 x86_64-linux-gnu-gcc

Sudo RM gcc

Sudo ln-s gcc-4.1 gcc

 

Ls-La | grep g ++

Sudo Rm-RF./g ++

Sudo Rm-RF x86_64-linux-gnu-g ++

Sudo ln-s x86_64-linux-gnu-g ++-4.1 x86_64-linux-gnu-g ++

Sudo ln-s g ++-4.1./g ++

 

# Check the version of GCC and G ++

GCC -- version

G ++ -- version

 

Cd ~ /Android_build

 

##### 4. Install arm GCC and jdk1.5 ##########

Sudo tar xzvf prebuilt-0f1763c.tar.gz-C/OPT

Sudo mV/opt/prebuilt-0f1763c // opt/arm-eabi-4.4.0/

Sudo jdk-1_5_0_22-linux-amd64.bin/opt/

CD/OPT

Sudo chmod A + x jdk-1_5_0_22-linux-amd64.bin

Sudo./jdk-1_5_0_22-linux-amd64.bin

 

##### 5. Install wine1.2 #####

Sudo apt-Get install wine1.2

 

##### 6. Create Android Build Environment profile ########

Echo "# Android profile"> Android. conf

Echo> Android. conf

Echo "java_home =/opt/jdk1.5.0 _ 22"> Android. conf

Echo "Export java_home"> Android. conf

Echo> Android. conf

Echo "android_java_home =/opt/jdk1.5.0 _ 22"> Android. conf

Echo "Export android_java_home"> Android. conf

Echo> Android. conf

Echo "Path =/opt/arm-eabi-4.4.0/bin:/opt/jdk1.5.0 _ 22/bin:/opt/android_sdk_2.1/tools:/opt/wine-1.1.33/bin: \ $ path "> android. conf

Echo "Export path"> Android. conf

 

Sudo MV Android. CONF/etc/

Source/etc/Android. conf

 

Echo "###################################### ###################"

Echo "# Oh, the android's environment has been build! ~ O ^_^ O ~ #"

Echo "###################################### ###################"

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.