Android source compilation

Keywords: Ubuntu sudo Java JDK

Android source compilation

Before compiling the source code, you need to do some preparation operations. The detailed steps are as follows:

1. Install JDK. Google requires JDK 1.8 to compile the latest version of source code

  • 1) . download JDK1.6 at: http://download.oracle.com/otn/java/jdk/6u45-b06/jdk-6u45-linux-x64.bin

  • 2) . create directory

    sudo mkdir /usr/java
    
  • 3) . copy the downloaded jdk-6u45-linux-x64.bin to the directory created above

    sudo cp /home/zhaokan/jdk-6u45-linux-x64.bin /usr/java
    
  • 4) . add executable rights

    sudo chmod 755 /usr/java/jdk-6u45-linux-x64.bin
    
  • 5) decompression.

    cd /usr/java
    sudo ./jdk-6u45-linux-x64.bin
    
  • 6) . configure environment variables

    export JAVA_HOME=/usr/java/jdk1.6.0_45
    export PATH=$PATH:$JAVA_HOME/bin
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
    
  • 7) . verify success

    zhaokan@zhaokan-VBox:~$ java -version
    java version "1.6.0_45"
    Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
    Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
    

2. Install other software dependent on compile time

Note: the source of ubuntu is relatively slow, and some software cannot be found, so you need to modify it to a domestic source. The steps to modify the source are as follows:

  • 1) . back up the source of ubuntu

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
    
  • 2) . modify source file

    sudo gedit /etc/apt/sources.list
    
  • 3) . a text edit box will pop up. Delete all contents first, then copy the following contents and save them

    deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
    
    deb http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse
    
    deb http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse
    deb http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse
    deb http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse
    deb http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse
    deb http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse
    deb-src http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse
    deb-src http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse
    deb-src http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse
    deb-src http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse
    deb-src http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse
    
  • 4) . after saving, update the data source

    sudo apt-get update
    
  • After the above steps are executed, the data source is updated, and the software dependent on compilation is installed. Similarly, enter the following commands in the terminal in the unit of behavior:

    sudo apt-get install gnupg
    sudo apt-get install flex
    sudo apt-get install bison
    sudo apt-get install gperf
    sudo apt-get install zip
    sudo apt-get install curl
    sudo apt-get install build-essential
    sudo apt-get install libesd0-dev
    sudo apt-get install libwxgtk2.8-dev
    sudo apt-get install libsdl-dev
    sudo apt-get install lsb-core
    sudo apt-get install lib32readline-gplv2-dev
    sudo apt-get install g++-multilib
    sudo apt-get install lib32z1-dev
    sudo apt-get install libswitch-perl
    

3. Start compiling. In the source directory, execute the following command:

    make

Posted by joeywoodbury on Sun, 09 Feb 2020 08:49:09 -0800