本文主要是将编译Android8.1过程中遇到问题记录下来,下载编译Android源码过程移步 下载编译Android6。
前提:下载源码,编译
编译过程中遇到的问题
主要是jack-server的问题,有的问题我用了好几种方案,在这里也都一一记录下来。
先贴几条jack server常用命令
. prebuilts/sdk/tools/jack-admin list-server
. prebuilts/sdk/tools/jack-admin start-server
. prebuilts/sdk/tools/jack-admin kill-server
-
Q1.
SSL error when connecting to the Jack server.see Jack server log```
or
Failed to contact Jack server: Problem reading /home/user3/.jack-server/client.pem. Try ‘jack-diagnose’
or
Jack server failed to (re)start,try ‘jack-diagnose’ see Jack server log
解决过程:根据提示运行
`. prebuilts/sdk/tools/jack-diagnose`
看到日志详情为port被占用。
#### R1:
思路1:
1).从/etc/java-8-openjdk/security/java.security file中删除TLSv1, TLSv1.1
2).依次运行`cd /prebuilts/sdk/tools/`、`./jack-admin kill-server`、`./jack-admin start-server`并查看结果
思路2:更改端口号
打开~/.jack-settings 和 ~/.jcak-server/config.properties 换成其他端口号。比如8976/8977。注意两个文件中两个对应端口号需要一致。
思路3:jdk版本问题。本人实践过程中自下载的openJDK1.8.0版本会报端口被占用问题,测试运行`. /prebuilts/sdk/tools/jack-diagnose`打印log会提示端口被占用, 换其他未使用的端口依然如此。解决方法,使用android源码自带得到JDK。(**路径:prebuilts/jdk/**)(我用此种方式)。
也可以使用自行下载其他版本的openJDK, 卸载Android服务器自带jdk。
思路4:删除~/.jack-settings 和 ~/.jcak-server/config.properties 重新编译。(prebuild/sdk/tools/目录下执行./jack-admin install-server jack-launcher.jar jack-server-4.11.ALPHA.jar 命令生成 .jack-server文件。jack-launcher.jar 和 jack-server-4.11.ALPHA.jar 这两个文件根据你的prebuilts/sdk/tools 目录下的文件名而定)
试过1、2、3,大概率3解决的,为什么用自行下载的openJDK1.8不行,原因还不知道,若有大神知道欢迎留言。
* #### Q2:timeout
Connection to the Jack server timeout, retrying with debug.Hostname was NOT found in DNS cache
Connection to the Jack server timeout, retrying with debug
- Hostname was NOT found in DNS cache
- Trying 127.0.0.1...
- Connected to localhost (127.0.0.1)port 8076 (#0)
- successfully set certificate verify locations:
- CAfile: /root/.jack-server/server.pem
CApath: /etc/ssl/certs - SSLv3, TLS handshake, Client hello (1):
} [data not shown] - Operation timed out after 0 milliseconds with 0 out of 0 bytes received
- Closing connection 0
Building with Jack:...r_intermediates/with-local/classes.dex
ninja: build stopped: subcommand failed.
#### R2:
`sudo ufw disable` 关闭防火墙
`sudo git config --global http.sslVerify false` 关闭ssl校验
然后重新make
* #### Q3:Jack server OOM
Out of memory error ...ninja: build stopped: subcommand failed.
17:56:49 ninja failed with: exit status 1
#### R3:
`free -h`看一下内存情况,内存不够的话设置一下,执行一下:
`export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"`
如果`free -h`看到cache过大,可以执行`sudo sh -c "echo 1 > /proc/sys/vm/drop_caches"`再看看内存情况,应该就变小了,再编译看看,应该就好了,如果还不行,试试设置大一点的swap分区
* ####Q4:磁盘空间不足
trace write error:write out/build.trace.gz:no space left on device
low disk space on home
R4:执行`df /home`查看磁盘使用清空。
删除大文件
参考:
https://stackoverflow.com/questions/67363030/rebuild-android-code-with-error-ssl-error-when-connecting-to-the-jack-server-t
https://copyfuture.com/blogs-details/20211204042512182U
https://blog.csdn.net/hongmao6/article/details/119822374https://blog.csdn.net/haijiaoningxia/article/details/102561765