Android 11(R) 源码下载+编译

0. introduce

系统 Ubuntu16.04
/etc/apt/sources.list
'
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb https://download.docker.com/linux/ubuntu trusty main
# deb-src https://download.docker.com/linux/ubuntu trusty main
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
'

1. ready

下载指定版本的android源码(此处是R)
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
./repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r17
./repo sync
出现错误的话,一直执行./repo sync
如果出现如下错误:
error: Cannot checkout platform/cts: ManifestInvalidRevisionError: revision refs/tags/android-11.0.0_r17 in platform/cts not found
error: in `sync -c platform/cts`: revision refs/tags/android-11.0.0_r17 in platform/cts not found
请使用
./repo sync -c platform/cts
有个小技巧,循环下载: repo_sync_project.sh project.list
# project.list中主要是那些不容易下载下来的project
#! /bin/bash

CNT=1
while [ 1 ]
do
    echo $CNT
    cat $1|while read line
    do
    echo "packing $line"
    ./repo sync -c $line
    done
    let CNT+=1
done
或者
while [ 1 ]
do
    ./repo sync
done

2. compile

. build/envsetup.sh
lunch aosp_x86-eng
make -j16

3. 在Intellij IDEA中查看android源码

. build/envsetup.sh
make idegen
sudo development/tools/idegen/idegen.sh
// 可能出现如下错误(java版本过多导致)
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
// 解决办法是
sudo update-alternatives --config java
选择对应的java版本
// 最终生成
android.iml  android.ipr
// 在Intellij IDEA中打开android.ipr
// 就可以完美的查看调用关系.

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值