aosp - source code reading environment to build

1 Background

Android developers usually are looking at all the SDK source code, there are a lot of code in the SDK are hidden, and can not see. not on the mac source insight tool, toss a half-day vscode plug, failed to set the pass code for the skip function. Later, see the online version aosp preview website, the first one is androidxref , to experience good, that is slow to load, and later out of a domestic version androdxref , load a lot faster, but sometimes life and death does not come out to load large files, such as Activity. java loaded into only after hundreds of lines on a blank, the more want to see the load does not come out, hold back the very difficult subject. I have not often use the laptop, just to build a aosp preview service, but also save mac 100 Duo G hard disk space.

Ubuntu installed on the computer system, where select 14.04 version, because aosp versions are on ubuntu 14.04 test of.

2 Get the source

Download from the domestic aosp Mirror (Mirror open source software Tsinghua University Station): https: //mirror.tuna.tsinghua.edu.cn/help/AOSP

  1. Access https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar start downloading the latest month package, January 2020 I downloaded the latest package, there are 68G
  2. tar -xvf aosp-latest.tar directory and enter aosp
  3. Execute repo sync -lcheckout code for the current master checkout branch code
  4. Performing repo init -b android-8.0.0_r27the handover to a current branch android-8.0.0_r27(profile to the repo simply android-8.0.0_r27, the next step will be the source switch; another branch to see here )
  5. Performing repo sync -c --no-clone-bundle --no-tags -j4the handover to the sourceandroid-8.0.0_r27

repo Introduction

3 Establish Source Index

  1. Perform sudo apt-get install openjdk-8-jdkinstallation openjdk-8, if not able to find the package, on the implementation of sudo add-apt-repository ppa:openjdk-r/ppaadding apt libraries, update and then install
  2. Download tomcat 8 , unpacked into the bin directory and execute ./startup.shstart tomcat
  3. Install universal-ctags
  4. Set OpenGrok
    1. Download the latest version OpenGrok
    2. Creating OpenGrok project directory, create a root directory mkdir grok, enter grok execute mkdir src data dist etc logcreate jobs directory
    3. The download opengrok-xxxtar.gz parsing the opengrok-xxx files all transferred to Step 2 dist directory
    4. Copy ./doc/logging.properties to ./etc/
  5. Aosp create an index file, execute ./indexer.shthe script file below, this process is very long and there will be many warnings thrown, but does not affect the main function
  6. Visit http: // localhost: 8080 / source should see a preview OpenGrop home, and there will be android-8.0.0_r27 source directory

indexer.sh follows

# /home/lgd/grok 为 OpenGrok 根目录,应该替换成自己的目录再执行
java -Xmx12g \
    -Djava.util.logging.config.file=/home/lgd/grok/etc/logging.properties \
    -jar /home/lgd/grok/dist/lib/opengrok.jar \
    -c /usr/bin/ctags \
    -s /home/lgd/grok/src \
    -d /home/lgd/grok/data -H -P -S -G \
    -W /home/lgd/grok/etc/configuration.xml \
    -U http://localhost:8080/source \
    -m 256

Process found a blog a detailed record of how to export the AOSP Android Studio, feeling worth trying, still have time to put the code in the IDE to view, so easy to modify and debug.

# Problems encountered

The following appeared in the import Ide problems and solutions (to be continued)

All commands are executed in the root directory aosp

Question 1
execute source build/envsetup.shcommand

Traceback (most recent call last):
  File "/media/lgd/d/aosp/aosp/.repo/repo/main.py", line 531, in <module>
    _Main(sys.argv[1:])
  File "/media/lgd/d/aosp/aosp/.repo/repo/main.py", line 507, in _Main
    result = repo._Run(argv) or 0
  File "/media/lgd/d/aosp/aosp/.repo/repo/main.py", line 158, in _Run
    copts, cargs = cmd.OptionParser.parse_args(argv)
  File "/media/lgd/d/aosp/aosp/.repo/repo/command.py", line 67, in OptionParser
    self._Options(self._optparse)
  File "/media/lgd/d/aosp/aosp/.repo/repo/subcmds/sync.py", line 189, in _Options
    self.jobs = self.manifest.default.sync_j
  File "/media/lgd/d/aosp/aosp/.repo/repo/manifest_xml.py", line 360, in default
    self._Load()
  File "/media/lgd/d/aosp/aosp/.repo/repo/manifest_xml.py", line 428, in _Load
    self._ParseManifest(nodes)
  File "/media/lgd/d/aosp/aosp/.repo/repo/manifest_xml.py", line 537, in _ParseManifest
    project = self._ParseProject(node)
  File "/media/lgd/d/aosp/aosp/.repo/repo/manifest_xml.py", line 802, in _ParseProject
    relpath, worktree, gitdir, objdir = self.GetProjectPaths(name, path)
  File "/media/lgd/d/aosp/aosp/.repo/repo/manifest_xml.py", line 852, in GetProjectPaths
    worktree = os.path.join(self.topdir, path).replace('\\', '/')
  File "/usr/lib/python2.7/posixpath.py", line 80, in join
    path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 11: ordinal not in range(128)

Workaround: Add after main.py file, import statements

reload(sys)
sys.setdefaultencoding('utf8')

Question 2
execution sudo apt-get install openjdk-8-jdkprompted to find the installation package

Solution:

sudo add-apt-repository ppa:openjdk-r/ppa # 添加 openjdk 库
sudo apt-get update

sudo apt-get install openjdk-8-jdk

Question 3
compiled build / envsetup.sh complete, execute lunch aosp_x86_64-engprompt file permission error.

Workaround: Before moving on is hard to operate, a .bash file permissions -rx ------, using sudo chmod a+x file.bashpost-it can not change file attributes. Finally, all the test files to the computer on the issue disappeared.

Question 4
execute makewhen prompted:

build/make/core/base_rules.mk:589: warning: ignoring old commands for target `out/target/product/generic_x86_64/testcases/simpleperf_unit_test/testdata/wrong_ip_callchain_perf.data'
[ 99% 931/932] glob tools/apksig/src/main/java/**/*.java
[  0% 459/81763] Check module type: out/target/common/obj/APPS/Browser2_intermediates/link_type
packages/apps/Browser2/Android.mk: warning: Browser2 (java:sdk) should not link to legacy-android-test (java:platform)
[  0% 793/81763] build out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/annotated/timestamp
WARNING: duplicate annotation of type libcore.util.NonNull
WARNING: duplicate annotation of type libcore.util.NonNull
[  3% 2941/81763] Yacc: ss <= external/iproute2/misc/ssfilter.y
FAILED: out/target/product/generic_x86_64/obj/EXECUTABLES/ss_intermediates/ssfilter.c 
/bin/bash -c "prebuilts/misc/linux-x86/bison/bison -d  --defines=out/target/product/generic_x86_64/obj/EXECUTABLES/ss_intermediates/ssfilter.h -o out/target/product/generic_x86_64/obj/EXECUTABLES/ss_intermediates/ssfilter.c external/iproute2/misc/ssfilter.y"
/bin/bash: prebuilts/misc/linux-x86/bison/bison: 没有那个文件或目录
[  3% 2949/81763] target  C++: secdiscard <= system/vold/FileDeviceUtils.cpp
56 warnings generated.
[  3% 2950/81763] target  C++: secdiscard <= system/vold/secdiscard.cpp
58 warnings generated.
ninja: build stopped: subcommand failed.
20:58:10 ninja failed with: exit status 1

#### failed to build some targets (06:48 (mm:ss)) ####

Resolution: The
log for this sentence: prebuilts / misc / linux-x86 / bison / bison: No such file or directory solution is as follows:

sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

Domestic network to download slowly, need to replace apt warehouse source, backup /etc/apt/sources.listfiles, empty the entire contents within the file, add Ali apt source

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

Question 5

[  0% 24/78813] Yacc: ss <= external/iproute2/misc/ssfilter.y
FAILED: out/target/product/generic_x86_64/obj/EXECUTABLES/ss_intermediates/ssfilter.c 
/bin/bash -c "prebuilts/misc/linux-x86/bison/bison -d  --defines=out/target/product/generic_x86_64/obj/EXECUTABLES/ss_intermediates/ssfilter.h -o out/target/product/generic_x86_64/obj/EXECUTABLES/ss_intermediates/ssfilter.c external/iproute2/misc/ssfilter.y"
external/iproute2/misc/ssfilter.y: conflicts: 35 shift/reduce
[  0% 33/78813] Check module type: out/target/product/generic_x86_64/obj/EXECUTABLES/tc_intermediates/link_type
ninja: build stopped: subcommand failed.
21:51:18 ninja failed with: exit status 1

#### failed to build some targets (01:07 (mm:ss)) ####

Solution:
Use .repo from the repo sync -lcheckout the source code, the source code is the master branch at this time, the compiler will encounter strange problems Kiki, should switch to a release branch, do compile, such as switching to android-8.0.0_r27

repo sync -l
repo init -b android-8.0.0_r27
repo sync -c --no-clone-bundle --no-tags -j4

Question 6
does not Primula error logs, error content impression that the m4 compiler error, found that the environment is not installed m4, continue after the installation.

# 安装 m4
sudo apt-get install m4

Question 7

2 warnings generated.
[ 16% 9889/61548] Copy xml: out/target/product/generic/system/etc/apns-conf.xml
FAILED: out/target/product/generic/system/etc/apns-conf.xml 
/bin/bash -c "(xmllint device/generic/goldfish/data/etc/apns-conf.xml >/dev/null ) && (mkdir -p out/target/product/generic/system/etc/ ) && (rm -f out/target/product/generic/system/etc/apns-conf.xml ) && (cp device/generic/goldfish/data/etc/apns-conf.xml out/target/product/generic/system/etc/apns-conf.xml )"
/bin/bash: xmllint: 未找到命令
ninja: build stopped: subcommand failed.
09:06:00 ninja failed with: exit status 1
make: *** [run_soong_ui] 错误 1

Solution:

sudo apt-get install libxml2-utils

Question 8
can not find the command mmm

Solution:
re-run

source build/envsetup.sh

Question 9
Run repo sync -b --no-clone-bundle --no-tags -j4the following command errors

	28/system/api/com.android.media.tv.remoteprovi
正在终止
prebuilts/sdk/: discarding 1 commits
error: prebuilts/sdk/: platform/prebuilts/sdk checkout 2ba6c3807598071c98c37eb6fb5601493748041c 
error: Cannot checkout platform/prebuilts/sdk
prebuilts/tools/: discarding 1 commits
system/bt/: discarding 253 commits
system/chre/: discarding 14 commits
system/connectivity/wificond/: discarding 36 commits
system/core/: discarding 197 commits
system/extras/: discarding 80 commits
system/gatekeeper/: discarding 1 commits
system/hardware/interfaces/: discarding 7 commits
system/hwservicemanager/: discarding 29 commits
system/keymaster/: discarding 12 commits
system/libfmq/: discarding 15 commits
system/libhidl/: discarding 67 commits
system/libhwbinder/: discarding 15 commits
system/libufdt/: discarding 8 commits
system/libvintf/: discarding 37 commits
system/media/: discarding 49 commits
system/netd/: discarding 28 commits
system/nfc/: discarding 45 commits
system/nvram/: discarding 2 commits
system/security/: discarding 27 commits
system/sepolicy/: discarding 180 commits
system/tools/hidl/: discarding 90 commits
system/update_engine/: discarding 10 commits
system/vold/: discarding 21 commits
test/vts/: discarding 91 commits
test/vts-testcase/fuzz/: discarding 15 commits
test/vts-testcase/hal/: discarding 63 commits
test/vts-testcase/hal-trace/: discarding 5 commits
test/vts-testcase/kernel/: discarding 25 commits
test/vts-testcase/performance/: discarding 19 commits
test/vts-testcase/security/: discarding 4 commits
test/vts-testcase/vndk/: discarding 5 commits
tools/apksig/: discarding 5 commits
tools/external/gradle/: discarding 8 commits
tools/loganalysis/: discarding 12 commits
tools/test/connectivity/: discarding 94 commits
tools/tradefederation/contrib/: discarding 3 commits
tools/tradefederation/core/: discarding 82 commits
Checking out projects:  99% (587/588), done.

error: Exited sync due to checkout errors
Failing repos:
prebuilts/sdk

To solve the problem:
possible before the operation is forcibly interrupted midway lead to inconsistencies in the case file, the Internet to find that there delete .repo/prebuilts/sdk.gitdelete and re-sync, but I do not have this file .repo directory. Delete all files from the original .tar package re-extract a re-execute the command on ok

Released nine original articles · won praise 0 · Views 60

Guess you like

Origin blog.csdn.net/weixin_46221133/article/details/104090895