Compiling: Problems with Jack

Sometimes, Jack just doesn’t want to play. Here is the error I got while trying to compile AOSP 7.0 for the Samsung SGH-M919, T-Mobile S4:

[ 1% 73/5641] Ensure Jack server is installed and started
Jack server already installed in “/home/alaskalinuxuser/.jack-server”
Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/alaskalinuxuser/.jack-server/launcher.jar
[ 1% 74/5641] Building with Jack: out…k_intermediates/with-local/classes.dex
FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
Communication error with Jack server (52). Try ‘jack-diagnose’
ninja: build stopped: subcommand failed.
make: *** [ninja_wrapper] Error 1

And here is how I solved it:

$ export JACK_SERVER_VM_ARGUMENTS=”-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g”
$ ./prebuilts/sdk/tools/jack-admin kill-server
$ ./prebuilts/sdk/tools/jack-admin start-server

Essentially, Jack has an issue with regards to memory. What I have done here is give it more heap size to buffer the work that it is doing. I’ve done this by passing an argument to Jack through an environment variable. This variable will go away as soon as I close the terminal I am working in. I then stop and restart the Jack server.

This trick also works well if Jack tells you that you don’t have enough memory to compile something. You may get an error like this:

Try increasing heap size with ‘-Xmx<size>’

You can set the heap size to anything you want, but 4 GB worked pretty well for me.

Linux – keep it simple.


4 thoughts on “Compiling: Problems with Jack

    1. The version of jack you are using is probably 1.3, while this was written using version 1.1. Check the documentation for Jack servers on Android builds website.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s