'FAILED: setup-jack-server when building LineageOS

I'm attempting to build LineageOS for the Moto Z (griffin) on a server, but the build crashes and burns 5 minutes out the gate.

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 -Xmx16G\" 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/dablord/.jack-server"
Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx16G -cp /home/dablord/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
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'
[  3% 911/25667] //art/compiler:libart-compiler clang++ optimizing/instruction_builder.cc [linux x86]
ninja: build stopped: subcommand failed.
07:02:53 ninja failed with: exit status 1

The server is set up for personal use. It has 24GB RAM and 300GB of available storage. I also set up a 20GB swap file in case the Jack server somehow needed more.

The Jack log file reports the follwing:

07:29:02.699: INFO: com.android.jack.server.JackHttpServer: Loading config of jack server version: 1.3-a11 '1.3' (402300 704631c4e9bbfb4e8b052365140f79974b9f4cf4 by [email protected])                                            
07:29:02.747: INFO: com.android.jack.server.JackHttpServer: Starting service connection server on /127.0.0.1:8076
07:29:02.754: 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:785)
        at com.android.jack.server.JackServerImpl.run(JackServerImpl.java:67)
        at com.android.jack.launcher.ServerLauncher$3.run(ServerLauncher.java:392)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.BindException: Address already in use
        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:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        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:779)
        ... 3 more

I've attempted to change the port # in the jack config files, reinstalling jack, resyncing the repo, all to no avail.



Solution 1:[1]

I also ran into this problem and it appeared to be BOTH an issue with TLS, guessing the older build was trying to use an obsoleted TLS version, AND a memory issue.

TLS

I followed Error in building android image, fails with jack server:

  1. Edit java.security file under /etc/java-8-openjdk/security/
  2. Remove TLSv1, TLSv1.1 from jdk.tls.disabledAlgorithms
  3. Restart the jack server:
    jack-admin kill-server
    jack-admin start-server

Memory

NOTE: It's necessary for the build to first fail before running the following steps.

I followed the recommendation here: https://groups.google.com/g/android-building/c/8SQ0-4zZDo8, specifically, I needed to run

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx7000m"

AND

I modified ~/.jack-server/config.properties:

jack.server.max-service=1

Success

After that I was able to build LineageOS

Solution 2:[2]

Quick and dirty fix which bypasses the problem is disabling jack entirely following Yan's answer here. I'm leaving the question open however, since it doesn't actually solve the problem.

Solution 3:[3]

1.I made it past this error by adding and editing the following variables before building.

export LC_ALL

2.Edit java.security file under /etc/java-8-openjdk/security/

Remove TLSv1, TLSv1.1 from jdk.tls.disabledAlgorithms Restart the jack server:

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

3.. build/envsetup.sh

4.Run brunch command

brunch lineage_jfltexx-userdebug

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Cowbolt
Solution 3 e.moradi