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:

[CODE]
[ 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 -Djava.io.tmpdir=/tmp -Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp /home/alaskalinuxuser/.jack-server/launcher.jar com.android.jack.launcher.ServerLauncher
[ 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
[/CODE]

And here is how I solved it:

[CODE]
$ 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
[/CODE]

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:

[CODE]
FAILED: ….
Try increasing heap size with ‘-Xmx<size>’
[/CODE]

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

Linux – keep it simple.

Advertisements

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.

      Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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