Foreword
Because my computer is Ubuntu18 version, after successfully compile xposed brush into the phone does not start, check all the environment, there is no problem, the problem may be found compatible with the library system Ubuntu, but I can not reinstall the system, after all, a little stupid, so the best way is in Ubuntu container docker's compilation, unified environment can also be isolated from the environment usually
work development environment, began to operate below
Installation configuration docker
docker accelerated adoption of people-friendly image address
By modifying the daemon configuration file /etc/docker/daemon.json
to use the accelerator, execute the following command:
You can configure the daemon uses Docker Docker official mirror acceleration by default. So you can pull the default Mirror Mirror accelerated by the official, without specifying when each pullregistry.docker-cn.com
Temporary effect: You can guard pass --registry-mirror parameters process started in Docker:$ docker --registry-mirror=https://registry.docker-cn.com daemon
Permanently subject to change, you can modify /etc/docker/daemon.json file and add the registry-mirrors key.
$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
Pulling Ubuntu mirror
Since we compiled the system is Android 6.0, it is recommended to use Ubuntu 14.04 x64 systems to compile, save a lot of trouble (for example: compiler version, build kit version, the version dependencies such as incompatibility issues), which is why we use the docker the reason.
Execute the following command takes a snapshot:
$ sudo docker pull ubuntu:14.04 # docker默认都是64位系统
Query local mirror
Query existing local mirror (Note that mirror number -IMAGE ID)
$ sudo docker images
misty@ubuntu:/etc/docker$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04 2c5e00d77a67 6 weeks ago 188MB
rethinkdb latest cc5badcd88e8 7 weeks ago 184MB
nginx latest 53f3fd8007f7 7 weeks ago 109MB
openstf/stf latest f8f8d84596a0 7 weeks ago 784MB
sorccu/adb latest 7123ee61b746 15 months ago 30.5MB
openstf/ambassador latest b1f0eb8297cf 3 years ago 6.46MB
Check local container
misty@ubuntu:/etc/docker$ sudo docker ps -a
Boot image
Used herein 仓库:标签
manner sudo docker run -it ubuntu:14.04 /bin/bash
so that you get a pseudo-terminal
# 启动镜像,并获取一个伪终端
# 注意:实际启动的是容器,启动镜像时会自动创建新容器并启动。
$ sudo docker run -it <REPOSITORY:TAG> /bin/bash # 使用 仓库名+标签 启动
$ sudo docker run -it <IMAGE ID> /bin/bash # 使用 IMAGE ID 启动
# 退出镜像
>> $ exit # 或使用快捷键 Ctrl + D
Replace the system source
It seems used here
vi
will be a little problem, it is recommended to write using redirects way, modify the configuration docker reference image address
>> # cp /etc/apt/sources.list /etc/apt/sources.list.bak
>> # echo "新的数据源" > /etc/apt/sources.list // 使用新的数源替换
>> # apt-get update
>> # exit
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
Add Chinese language support
Add Chinese language support
after the start of the specified container into the interior of the container Ubuntu do:
>> $ locale #查询当前语言
>> $ locale -a #查询支持的语言
# 若不支持UTF-8,则添加UTF-8语言支持
>> $ apt-get install language-pack-zh-hant language-pack-zh-hans # 中文
>> $ language-pack-en # 英文
# 修改 /etc/profile 文件,添加:
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:zh
# 重新加载资源
>> $ source /etc/profile
Correct time zone
After starting Ubuntu specified container into the interior of the container do:
>> $ date # 查看当前时间
>> $ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
>> $ echo 'Asia/Shanghai' >/etc/timezone
Configuring the Compile special mirror
Create a container using the following command, and mount the ~/share
directory to the container /home/share
catalog:
$ docker run -it -v ~/share:/home/share ubuntu:14.04 /bin/bash
Description: Here a directory to mount the container to facilitate future operations.
Add 64-bit 32-bit system supports
1> check whether support
>> $ dpkg --print-architecture # 若支持,输出 amd64
>> $ dpkg --print-foreign-architectures # 若支持,输出 i386
Manually open support
>> $ sudo dpkg --add-architecture i386
>> $ sudo apt-get update
Update all software (not necessary)
>> $ sudo apt-get dist-upgrade
Only install support libraries (original need to install ia32-libs, currently being replaced by the following three libraries)
$ sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0
Add Android source code compiler required dependencies
to install the compiler and build tools package:
$ sudo apt-get install gcc-multilib g++-multilib build-essential
Install the necessary software tools
>> $ sudo apt-get install git-core gnupg bison flex gperf pngcrush bc zip curl lzop
>> $ sudo apt-get install schedtool libxml2 libxml2-utils xsltproc squashfs-tools
Install additional libraries needed
>> $ sudo apt-get install libesd0-dev libsdl1.2-dev libwxgtk2.8-dev libswitch-perl
>> $ sudo apt-get install libssl1.0.0 libssl-dev lib32readline-gplv2-dev libncurses5-dev
Annex: Command:
bc 命令行计算器
lzop 快速压缩工具
flex 词法分析器生成器
curl 基于URL的文件传输工具
gperf 哈希函数生成器
bison 语法分析器生成器
xsltproc 快速XSLT引擎,可以通过XSL文件把XML转为HTML,XHTML,PDF...
schedtool 查询或设置CPU状态
squashfs-tools linux内核压缩工具,只读式压缩文件系统Image
pngcrush 批量压缩PNG图片
libxml2 libxml2-utils 操作XML文档工具
Save the container is submitted mirror
After configuring the environment, saving the container as a mirror:
$ sudo docker commit -m "xxx" <CONTAINER ID> <TEPO:TAG>
For example, use the $ docker ps -a
command query container number just for 1a61adfb1953, we save it as a local mirror, you can do:
$ sudo docker commit -m "local_ubuntu14" 7e242d3a00ae local_ubuntu14:ubuntu_v1.0
$ Docker images can be viewed using the newly generated image:
misty@ubuntu:~/share$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
local_ubuntu14 ubuntu_v1.0 97793b37c017 15 seconds ago 796MB
ubuntu 14.04 2c5e00d77a67 6 weeks ago 188MB
rethinkdb latest cc5badcd88e8 7 weeks ago 184MB
nginx latest 53f3fd8007f7 7 weeks ago 109MB
openstf/stf latest f8f8d84596a0 7 weeks ago 784MB
sorccu/adb latest 7123ee61b746 15 months ago 30.5MB
openstf/ambassador latest b1f0eb8297cf 3 years ago 6.46MB
The starting container submitted local mirror, a host of the host to mount source directory Android mirror directory aosp
sudo docker run -it -v ~/bin:/home/aosp local_ubuntu14 /bin/bash
Preparation before the compiler environment - environment list
The host system: ubuntu18.0.4LTS
Host: java Version "1.8.0_211"
Docker Server Version: 18.09.5
Kernel Version: 4.18.0-25-the Generic
Mirror: ubuntu 14.04
in the container Source Version: android-6.0.1_r11
the container java version: java version "1.7.0_201"
Compile Before Use
- docker relevant documents are in the
/var/lib/docker
directory
I began to compile Android source code and xposed
- Into the interior of the container
sudo docker exec -it [容器id] /bin/bash
2 .. perl configuration environment to configure the Android source compiled articles
- Here I was in Ubuntu inside compiled XposedBridge, inside the container compile xposed (note modify configuration files and output directory), this advantage is that you can separate environment, Ubuntu configuration inside Java8, inside the container configuration Java7, it is mainly too lazy to install configuration over environment , anyway, the mapping is the same source directory
- Under homed host XposedTools project
./buile.pl -a java
began compiling XposedBridge
- Under homed host XposedTools project
- Start compiling Xposed
- XposedBridge before compilation to check on the output of the Java directory folders, Xposed project
$aosp/frameworker/bash/cmds/xposed
, xposed_art in$aosp/art
replacing the original art source directory, and switch to the corresponding source code version of the branch; - Under homed host XposedTools project
./buile.pl -t arm64:23
began compiling Xposed,
- XposedBridge before compilation to check on the output of the Java directory folders, Xposed project
Common problem solving
USER problem (due to the operation of the docker is not configured USER environment variable)
including ./tools/external/fat32lib/Android.mk ...
Install: out/host/linux-x86/framework/jack.jar
out/host/linux-x86/bin/jack-admin: line 27: USER: unbound variable
make: *** [out/host/linux-x86/framework/jack.jar] Error 1
make: *** Deleting file `out/host/linux-x86/framework/jack.jar'
#### make failed to build some targets (41 seconds) ####
Solution:
export USER=$(whoami)
- Alternatively
ENV USER root
// can also be a name they need
Detailed error logs
Last 10 lines from the log:
target Unpacked: patchoat (out/target/product/generic_arm64/obj_arm/EXECUTABLES/patchoat_intermediates/PACKED/patchoat)
target Symbolic: patchoat (out/target/product/generic_arm64/symbols/system/bin/patchoat)
target Strip: patchoat (out/target/product/generic_arm64/obj_arm/EXECUTABLES/patchoat_intermediates/patchoat)
Install: out/target/product/generic_arm64/system/bin/patchoat
collect2: error: ld returned 1 exit status
make: *** [out/target/product/generic_arm64/obj_arm/SHARED_LIBRARIES/libxposed_art_intermediates/LINKED/libxposed_art.so] Error 1
make: *** Waiting for unfinished jobs....
#### make failed to build some targets (04:32 (mm:ss)) ####
Because before Ubuntu18 the compiled source code directly take over the emergence of this issue, in the source directory to perform git status
discovery changed cang editor, well, direct reduction environment, re-pull xposed_art on guthub art6.0 corresponding points, recompile really do not have this problem, and successfully compiled by
Boot interface card settlement
After successful compilation brush into the phone card at the boot screen, access logs
Failed to dlopen libart.so: dlopen failed: cannot locate symbol "__android_log_error_write" referenced by "/system/lib64/libart.so"...
Android.mk compiled script error in your library libxxx.so please add: LOCAL_LDFLAGS + = -fuse-ld = bfd
# 直接追加的方式
ifeq (1,$(strip $(shell expr $(PLATFORM_SDK_VERSION) \>= 22)))
LOCAL_WHOLE_STATIC_LIBRARIES := libsigchain
LOCAL_LDFLAGS := -Wl,--version-script,art/sigchainlib/version-script.txt -Wl,--export-dynamic
LOCAL_LDFLAGS += -fuse-ld=bfd
endif
After this turn, may report: unrecognized option '-icf = safe'
Sure enough, the following compilation errors after modification
Last 10 lines from the log:
target Symbolic: xposed (out/target/product/generic_arm64/symbols/system/bin/app_process64_xposed)
target Strip (keep symbols): xposed (out/target/product/generic_arm64/obj/EXECUTABLES/xposed_intermediates/app_process64_xposed)
/home/aosp/WORKING_DIRECTORY/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld.bfd: unrecognized option '--icf=safe'
/home/aosp/WORKING_DIRECTORY/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/../lib/gcc/arm-linux-androideabi/4.9.x-google/../../../../arm-linux-androideabi/bin/ld.bfd: use the --help option for usage information
collect2: error: ld returned 1 exit status
make: *** [out/target/product/generic_arm64/obj_arm/EXECUTABLES/xposed_intermediates/LINKED/app_process32_xposed] Error 1
make: *** Waiting for unfinished jobs....
#### make failed to build some targets (43 seconds) ####
Solution:
Modify TARGET_linux-arm.mk
the P134 line of the TARGET_GLOBAL_LDFLAGS
assignment, remove–icf=safe
This path using the following command to find out, the next source directory
find ./ -iname TARGET_linux-arm.mk
;
the path is$aosp/build/core/combo/TARGET_linux-arm.mk
Just try the above two methods, in fact, does not solve the problem, the second is a direct result of the compiler can not pass; after successfully solve the problem by reconfiguring a unified environment, the brush into the phone perfect run
Successfully compiled container submitted for the root partition mirrored lead to full
sudo docker commit "commit images" [containerId] myaosp:v1.0
;
To perform half of the root directory full, Oh, and quickly ctrl +c
terminated, it could mount a directory aosp host with me inside the container and pull a new AOSP a relationship, too much data,
solution:
a temporary solution: find online a lot of ways to clean up the feeling of Linux operability is not strong, after all, related to the clean-up file or cautious good, but do not want a move back to liberation, the first part of it is released to restart docker
启动 systemctl start docker (这条命令即可)
守护进程重启 sudo systemctl daemon-reload
重启docker服务 systemctl restart docker
重启docker服务 sudo service docker restart
关闭docker service docker stop
关闭docker systemctl stop docker
Written in the last
References to thank the bloggers offered the use of Docker Android system source code compilation
Small indeed fortunate
每一丝灵感都值得被记录,每一笔记录都是成长,每一点成长都值得欢呼
Personal bloggers station: www.imisty.cn
CSDN blog: https://blog.csdn.net/lookinthefog
blog Park: https://imist.cnblogs.com/
Hope to know some tech-savvy small partner, welcome to the Friends link yo