Communication error with Jack server , try ‘jack-diagnose‘ or see Jack server log 报错解决办法

Communication error with Jack server , try 'jack-diagnose' or see Jack server log 报错解决办法

报错log如下:

[100% 1/1] Ensure Jack server is installed and started
FAILED: /bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.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.8.ALPHA.jar 4.8.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47; prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )"
Jack server already installed in "/home/songzhihao/.jack-server"
Communication error with Jack server (77), try 'jack-diagnose' or see Jack server log
Failed to contact Jack server: Problem reading /home/songzhihao/.jack-server/server.pem. Try 'jack-diagnose'
Failed to contact Jack server: Problem reading /home/songzhihao/.jack-server/server.pem. Try 'jack-diagnose'
ninja: build stopped: subcommand failed.
build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1

这里意思是说启动jack server失败,我们在prebuilts下用jack-admin命令确实是启动不了。

android/prebuilts/sdk/tools$ ./jack-admin start-server

为什么会出现这种情况呢,我对比了其他同事的**.jack-server** 目录和 .jack-settings文件发现如下不同。

这是同事的jack-server目录文件

liush@Ubunbtu-jcrjb-04:~/.jack-server$ ls -l
total 8952
-rw------- 1 liush liush    2094 Jan 29  2018 client.jks
-rw------- 1 liush liush    2806 Apr  8 19:22 client.pem
-rw------- 1 liush liush     282 Jan 29  2018 config.properties
drwxrwxr-x 2 liush liush    4096 Jan 29  2018 jack
-rw------- 1 liush liush 4378061 Jan 29  2018 launcher.jar
drwx------ 2 liush liush    4096 Apr  8 19:22 logs
-rw------- 1 liush liush 4758810 Jan 29  2018 server-1.jar
-rw------- 1 liush liush    2067 Jan 29  2018 server.jks
-rw------- 1 liush liush    1042 Apr  8 19:22 server.pem

这个是我的,发现我缺少config.properties文件。

songzhihao@Ubunbtu-jcrjb-04:~/.jack-server$ ll -s
total 8948
   4 drwx------ 4 songzhihao songzhihao    4096 Apr  8 19:46 ./
   4 drwxr-xr-x 6 songzhihao songzhihao    4096 Apr  8 19:43 ../
   4 -rw------- 1 songzhihao songzhihao    2103 Apr  8 17:32 client.jks
   4 drwxrwxr-x 2 songzhihao songzhihao    4096 Apr  8 19:31 jack/
4276 -rw------- 1 songzhihao songzhihao 4378061 Apr  8 17:32 launcher.jar
   4 drwx------ 2 songzhihao songzhihao    4096 Apr  8 19:30 logs/
4648 -rw------- 1 songzhihao songzhihao 4758810 Apr  8 17:32 server-1.jar
   4 -rw------- 1 songzhihao songzhihao    2067 Apr  8 17:32 server.jks

打开/.jack-server/log/里面的log发现报错的地方是打开端口号错误了,通过查找其他解决办法,试了一下修改端口号的解决办法,发现是有效的,具体如下。

19:22:30.131: INFO: com.android.jack.server.JackHttpServer: Starting jack server version: 1.3-a8 '1.3' (291201 fcd657165d2fd6dcf1bf4c3002c9c8f75383e815 by android-jack-team@google.com)
19:22:30.160: INFO: com.android.jack.server.JackHttpServer: Starting service connection server on /127.0.0.1:8
19:22:30.165: SEVERE: com.android.jack.launcher.ServerLauncher: Server 1 Exception
com.android.jack.server.api.v01.ServerException: Problem while opening service port
        at com.android.jack.server.JackHttpServer.start(JackHttpServer.java:611)
        at com.android.jack.server.JackServerImpl.run(JackServerImpl.java:62)
        at com.android.jack.launcher.ServerLauncher$3.run(ServerLauncher.java:391)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Permission denied
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:220)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85)
        at com.android.jack.server.ServerParameters.openSocket(ServerParameters.java:88)
        at com.android.jack.server.ServerParameters.getServiceSocket(ServerParameters.java:67)
        at com.android.jack.server.JackHttpServer.start(JackHttpServer.java:605)
        ... 3 more

1、 SERVER_PORT_SERVICE 和 SERVER_PORT_ADMIN 的端口号改大点的数字,不要和别人重复。

songzhihao@Ubunbtu-jcrjb-04:~$ cat .jack-settings 
# Server settings
SERVER_HOST=127.0.0.1
SERVER_PORT_SERVICE=8926 
SERVER_PORT_ADMIN=8927

# Internal, do not touch
SETTING_VERSION=4

2、在.java-server目录下新建config.properties 文件,内容如下,注意这里的service.port 和admin.port要和上面.jack-settings里面的一样。

#
#Thur April 8 20:08:16 CST 2021
jack.server.max-jars-size=104857600
jack.server.max-service=4
jack.server.service.port=8926
jack.server.max-service.by-mem=1\=2147483648\:2\=3221225472\:3\=4294967296
jack.server.admin.port=8927
jack.server.config.version=2
jack.server.time-out=7200

3、最后给 .java-server/config.properties chmod 600 的权限,这样编译任何模块就可以编译通过了。Communication error with Jack server , try ‘jack-diagnose‘ or see Jack server log 报错解决办法

注意:如果改完config.properties还是报端口打开错误,试着进入android/prebuilts/sdk/tools目录执行下面的命令将 jack-server重启一下。

jack-admin kill-server jack-admin start-server

希望这篇文章对遇到同样报错的同学有帮助,有用的话就点个赞吧 !

上一篇:第02周学习提升建议:【python安装、变量、输入输出、流程、循环】--【第三篇】输入和输出


下一篇:Python学习笔记2:字典