当前位置: 代码迷 >> 综合 >> Android 编译(2)——jack-server相关问题
  详细解决方案

Android 编译(2)——jack-server相关问题

热度:7   发布时间:2024-01-10 21:40:16.0

Jack server

The Jack server’s goal is to handle a pool of Jack compiler instances in order to limit memory usage and benefit from already warm instances.

Android7.0系统编译工具链使用了全新的Jack server来取代以往的编译器工具

Jack is a new Android toolchain that compiles Java source into Android dex bytecode. It replaces the previous Android toolchain, which consists of multiple tools, such as javac, ProGuard, jarjar, and dx.
Jack编译器工具是一套新的Android编译工具用来将Java代码转换为Android dex字节代码。

使用问题

Jack server没有安装

报错信息:

Jack server installation not found
prebuilts/sdk/tools/jack-admin: line 57: /home/forlinx/.jack-settings.14348: Permission denied

安装jack-server

cd prebuilts/sdk/tools/
./jack-admin install-server jack-launcher.jar jack-server-4.8.ALPHA.jar

多用户使用问题

参考链接:
https://www.jianshu.com/p/dc85817b78f8?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendationhttps://blog.csdn.net/czy_1125/article/details/78432018https://blog.csdn.net/xw13782513621/article/details/79260207

报错信息:

Jack server already installed in "/home/forlinx/work/.jack-server"
Communication error with Jack server (35), try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'
SSL error when connecting to the Jack server. Try 'jack-diagnose'
重新安装配置Jack server
OK3399-android7-source$ rm ~/.jack-server -rf
OK3399-android7-source$ rm ~/.jack-settings
OK3399-android7-source$ cd prebuilts/sdk/tools/
OK3399-android7-source/prebuilts/sdk/tools$  ./jack-admin install-server jack-launcher.jar jack-server-4.8.ALPHA.jar执行jack-diagnose进行诊断
OK3399-android7-source/prebuilts/sdk/tools$ chmod u+x jack-diagnose
OK3399-android7-source/prebuilts/sdk/tools$ ./jack-diagnose
发现有部分库文件没有安装
OK3399-android7-source/prebuilts/sdk/tools$ sudo apt-get update
OK3399-android7-source/prebuilts/sdk/tools$ sudo apt-get install lsof
OK3399-android7-source/prebuilts/sdk/tools$ ./jack-diagnose

多用户的使用需要在.jack-settings和.jack-server/config.properties这两个配置文件中配置不同的端口
用户A:8000、8001

vi ~/.jack-settings# Server settings
SERVER_HOST=127.0.0.1
SERVER_PORT_SERVICE=8000
SERVER_PORT_ADMIN=8001# Internal, do not touch
SETTING_VERSION=4
vi ~/.jack-server/config.properties#
#Fri Sep 10 07:22:55 UTC 2021
jack.server.max-jars-size=104857600
jack.server.max-service=4
jack.server.service.port=8000
jack.server.max-service.by-mem=1\=2147483648\:2\=3221225472\:3\=4294967296
jack.server.admin.port=8001
jack.server.config.version=2
jack.server.time-out=7200

用户B:8100、8101

vi ~/.jack-settings# Server settings
SERVER_HOST=127.0.0.1
SERVER_PORT_SERVICE=8100
SERVER_PORT_ADMIN=8101# Internal, do not touch
SETTING_VERSION=4
vi ~/.jack-server/config.properties#
#Mon Sep 13 02:07:47 UTC 2021
jack.server.max-jars-size=104857600
jack.server.max-service=4
jack.server.service.port=8100
jack.server.max-service.by-mem=1\=2147483648\:2\=3221225472\:3\=4294967296
jack.server.admin.port=8101
jack.server.config.version=2
jack.server.time-out=7200

config.properties文件在第一次编译之前没有生成,可以先执行一遍编译,再进行修改

OK3399-android7-source/prebuilts/sdk/tools$ vi /home/forlinx/work/.jack-settings
编译源码,报错后修改新生成的config.properties,端口配置保持一致
OK3399-android7-source/prebuilts/sdk/tools$ vi /home/forlinx/work/.jack-server/config.properties
编译即可通过

question3

Could not execute 'apt-key' to verify signature (is gnupg installed?)
sudo chmod 777 /tmp

question4

Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log
No Jack server running. Try 'jack-admin start-server'
No Jack server running. Try 'jack-admin start-server'
ninja: build stopped: subcommand failed.
build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
重新安装配置Jack server
OK3399-android7-source$ rm ~/.jack-server -rf
OK3399-android7-source$ rm ~/.jack-settings
OK3399-android7-source$ cd prebuilts/sdk/tools/
OK3399-android7-source/prebuilts/sdk/tools$  ./jack-admin install-server jack-launcher.jar jack-server-4.8.ALPHA.jar执行jack-diagnose进行诊断
OK3399-android7-source/prebuilts/sdk/tools$ chmod u+x jack-diagnose
OK3399-android7-source/prebuilts/sdk/tools$ ./jack-diagnose

有可能会遇到多用户端口问题,所以建议提前修改配置.jack-settings和.jack-server/config.properties

TBC(jack server安装、与openjdk对比、用于编译什么内容、运行机制)

  相关解决方案