SoFunction
Updated on 2025-03-04

Solve the problem of Android source code compilation errors

As shown below:

Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/
FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/
Out of memory error (version 1.2-a26 'Carnac' (291201 fcd657165d2fd6dcf1bf4c3002c9c8f75383e815 by android-jack-team@)).
GC overhead limit exceeded.
Try increasing heap size with java option '-Xmx<size>'.
Warning: This may have produced partial or corrupted output.
ninja: build stopped: subcommand failed.

Fixed the -Xmx parameter in file /prebuilts/sdk/tools/jack-admin.

1. Change the variable JACK_SERVER_VM_ARGUMENTS, add parameters -Xmx2048M

JACK_SERVER_VM_ARGUMENTS="${JACK_SERVER_VM_ARGUMENTS:=-=UTF-8 -XX:+TieredCompilation -mx2048M}"

2. Further correct the restart parameters (this step can be omitted)

Find the start-server statement in jack-admin and add it directly:

start-server)

isServerRunning

RUNNING=$?

if [ "$RUNNING" = 0 ]; then

echo "Server is already running"

else

echo "before to start-server,JACK_SERVER_VM_ARGUMENTS=" $JACK_SERVER_VM_ARGUMENTS

JACK_SERVER_COMMAND="java -=$TMPDIR $JACK_SERVER_VM_ARGUMENTS-Xmx2048M -cp $LAUNCHER_JAR $LAUNCHER_NAME"

echo "Launching Jack server" $JACK_SERVER_COMMAND

(

Supplementary knowledge:Try increasing heap size with java option '-Xmx' error solution

This error occurs because the computer lacks memory. Execute the following three statements on the command line and then continue to compile.

export JACK_SERVER_VM_ARGUMENTS="-=UTF-8 -XX:+TieredCompilation -Xmx4g"

./prebuilts/sdk/tools/jack-admin kill-server
./prebuilts/sdk/tools/jack-admin start-server

The above article solves the problem of Android source code compilation errors is all the content I share with you. I hope you can give you a reference and I hope you can support me more.