当编译android8.1系统时,有时之前编译正常的,突然出现:
FAILED: setup-jack-server
/bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 4.11.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.32.CANDIDATE.jar 4.32.CANDIDATE || exit 47 )"
Jack server already installed in "/home/zhaojingrong/.jack-server"
Communication error with Jack server (60), try 'jack-diagnose' or see Jack server log
Failed to authenticate Jack server certificate. Try 'jack-diagnose'
Failed to authenticate Jack server certificate. Try 'jack-diagnose'
...............................................................
ninja: build stopped: subcommand failed.
11:50:50 ninja failed with: exit status 1
这个时候解决的办法如下:
1、修改 prebuilts/sdk/tools/jack-admin 文件,增加 ‘-Xmx’。如下我使用的是 -Xmx4G
- JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -cp $LAUNCHER_JAR $LAUNCHER_NAME"
+ JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -Xmx4096M -cp $LAUNCHER_JAR $LAUNCHER_NAME"
2、修改/home/.jack-setting文件,将SERVER_PORT_SERVICE和SERVER_PORT_ADMIN值从新修改一个端口号,如下:
$ vim /home/.jack-setting
SERVER_PORT_SERVICE=28076
SERVER_PORT_ADMIN=28077
換成:
SERVER_PORT_SERVICE=28023
SERVER_PORT_ADMIN=28022
3、修改/home/jack-server/config.properties文件,将SERVER_PORT_SERVICE和SERVER_PORT_ADMIN值从新修改一个端口号,跟/home/.jack-setting的端口号保持一致。如下:
$ vim /home/jack-server/config.properties
SERVER_PORT_SERVICE=28076
SERVER_PORT_ADMIN=28077
換成:
SERVER_PORT_SERVICE=28023
SERVER_PORT_ADMIN=28022
4、先杀掉jack-admin服务,然后再全系统编译即可,如下:
$ ./prebuilts/sdk/tools/jack-admin kill-server
以上的主要原因是,jack服务器和客户端的端口号被其它同事占用导致的,修改成同一网段内部其它同事没使用的端口号即可,防止出现jack编译的时候,有编译报错:Out of memory error的错误,将jack服务编译时单个进程最大修改到4G(加上这个参数-Xmx4G),注意编译机器的内存必须大于4G内存。