2018-05-17 AOSP Build脚本

Google/Android


【转Goood】自己动手编译Android源码(超详细)
【转Good】第一次编译AOSP简单流程


JDK: openjdk-8-jdk
https://source.android.com/setup/build/requirements#jdk

$ java -version
    openjdk version "1.8.0_171"
    OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11)
    OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

$ javac -version
    javac 1.8.0_171

HardDisk: 156G

$ du -sh android/
    156G    android/

Error 1
This error happens when using the wrong jdk version of openjdk-9-jdk.
Use openjdk-8-jdk will solve the problem.

   1 #
   2 # A fatal error has been detected by the Java Runtime Environment:
   3 #
   4 #  SIGSEGV (0xb) at pc=0x00007f84ef1a0304, pid=151912, tid=151989
   5 #
   6 # JRE version: OpenJDK Runtime Environment (9.0+181) (build 9+181-android4685155)
   7 # Java VM: OpenJDK 64-Bit Server VM (9+181-android4685155, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
   8 # Problematic frame:
   9 # V  [libjvm.so+0x942304]  PhaseLive::add_liveout(Block*, IndexSet*, VectorSet&)+0xe4
  10 #
  11 # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/xy2/workspa     ce/git/aic/android/core.151912)
  12 #
  13 # If you would like to submit a bug report, please visit:
  14 #   http://bugreport.java.com/bugreport/crash.jsp
  15 #

Error 2
emulator: ERROR: Missing initial data partition file: /home/xy2/workspace/git/aosp/android/out/target/product/generic_arm64/userdata.img


Scripte

#!/bin/bash

# add variables
i1=0
if [ "$1" ]; then
    i1=$1
fi


# add functions
function prompt()
{
    read -p "$1 [YES/NO]: " input
}

# script name
function myecho0script()
{
    echo
    echo '==========================================================='
    echo "$1"
    echo '==========================================================='
    echo
}

# task title
function myecho1task()
{
    echo
    if [ "$1" ]; then
        # 蓝底白字
        echo -e "\033[44;37m --> $i1. $1\033[0m"
    fi
    i1=$[$i1+1]
}

# things title
function myecho2thing()
{
    echo
    # 红色字
    #echo -e "\033[31m - $1 \033[0m"
    # 绿色字
    echo -e "\033[32m - $1 \033[0m"
    # 红底白字
    #echo -e "\033[41;37m- $1\033[0m"
}

# steps title
function myecho3step()
{
    echo
    echo -e " * $1"
}

# reference title
function myecho4ref()
{
    echo
    echo -e "\t$1"
    echo
}

# highlight title
function myechoy()
{
    echo
    # 黄底黑字
    echo -e "\033[43;30m$1\033[0m"
    #echo -e "\t\t$1"
}

# call outside script
function mysource()
{
    (source $1 $i1)
    i1=$[$i1+1]
}


# new chapter

myecho1task 'Build AOSP 20180517'
myecho3step 'https://source.android.com/setup/'
myecho3step 'https://www.jianshu.com/p/367f0886e62b'
myecho3step 'https://blog.csdn.net/l465659833/article/details/62237541'

#-----------------------------------------------------------------
myecho2thing 'Prerequisites'
myecho3step 'apt-get install'
    prompt '[Proxy...] set proxy properly'
    #sudo apt-get install -y libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev g++-multilib 
    #sudo apt-get install -y git flex bison gperf build-essential libncurses5-dev:i386 
    #sudo apt-get install -y tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 
    #sudo apt-get install -y dpkg-dev libsdl1.2-dev libesd0-dev
    #sudo apt-get install -y git-core gnupg flex bison gperf build-essential  
    #sudo apt-get install -y zip curl zlib1g-dev gcc-multilib g++-multilib 
    #sudo apt-get install -y libc6-dev-i386 
    #sudo apt-get install -y lib32ncurses5-dev x11proto-core-dev libx11-dev 
    #sudo apt-get install -y libgl1-mesa-dev libxml2-utils xsltproc unzip m4
    #sudo apt-get install -y lib32z-dev ccache


#myecho2thing 'Repo'
#myecho3step 'install'
    #mkdir ~/bin
    export PATH=~/bin:$PATH
    #curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    #chmod a+x ~/bin/repo

    #git config --global user.name "abby0100"
    #git config --global user.email "yuan.xiong@intel.com"


myecho2thing 'AOSP'
myecho3step 'repository'
    # Google
    #repo init -u https://android.googlesource.com/platform/manifest
    #repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.1_r6
    # tsinghua University
    #repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
    #repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest

    cd .repo/manifests/
    git branch
    git log -1
    #git branch -a | cut -d / -f 3
    #repo init -b android-7.1.1_r6
    cd -

#myecho3step 'sync'
    #repo sync
    #repo sync -cj16

myecho2thing 'JDK'
myecho3step 'openjdk-8-jdk'
    #prompt '[Install...] openjdk-8-jdk'
    #sudo add-apt-repository ppa:openjdk-r/ppa
    #sudo apt-get update
    #sudo apt-get install -y openjdk-8-jdk
myecho3step 'java'
    sudo update-alternatives --config java
    sudo update-alternatives --config javac


#-----------------------------------------------------------------
myecho2thing 'Make'
myecho3step 'env.'
    #make clobber
    #source build/envsetup.sh

myecho3step 'target'

    # For AOSP
    #lunch
    #lunch aosp_arm64-eng

    # For NuC
    #lunch multidroid_nuc-userdebug
    # For Server
    #lunch multidroid_cloud-userdebug

myecho3step 'make'
    #make -j16

    #prompt '#### build completed successfully (02:19:04 (hh:mm:ss)) ####'


#-----------------------------------------------------------------
myecho2thing 'Launch Emulator'
myecho3step 'env.'
    # not available
    #source build/envsetup.sh
    #lunch aosp_arm64-eng
    #emulator
    #emulator -gpu off


# new chapter
echo
#echo '==========================================================='
echo 'End'
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容