For whatever reason I can use neither 8076 nor 8077 on my server so I need to run the jack server on different ports.
Without choosing my own ports AOSP Master build fails at around 35% because it cannot connect to the jack server.
When I change ports in ~/.jack-settings to 8176/8177 build fails later, at around 55%, again because it cannot connect to the jack server.
I noticed that when ~/.jack-server/ is first generated the ports written to ~/.jack-server/config.properties are always the default 8076/8077 no matter the content of ~/.jack-settings
This suggests that jack uses the custom ports in ~/.jack-settings on first launch but writes the default ports to ~/.jack-server/config.properties. if (when?) the jack server stops during build, it is then restarted using the ports written in ~/jack-server/config.properties, which do not correspond to the values in ~/.jack-settings (and so on my server it always fails).
I manually changed the ports in ~/.jack-server/config.properties and commented out uninstall-server from
prebuilts/sdk/tools/jack_server_setup.mk to prevent ~/.jack-server/ from being regenerated and build now goes to completion.
Hopefully this is more than enough info to fix the bug.
Adam