Solve the problem of Android source code compilation error

  • 2021-11-24 02:54:13
  • OfStack

As shown below:

Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex
FAILED: /bin/bash out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rsp
Out of memory error (version 1.2-a26 'Carnac' (291201 fcd657165d2fd6dcf1bf4c3002c9c8f75383e815 by android-jack-team@google.com)).
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.

Modify the-Xmx parameter in document/prebuilts/sdk/tools/jack-admin.

1. Modify the variable JACK_SERVER_VM_ARGUMENTS and add the parameter-Xmx2048M

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

2. Step 1 to correct 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 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS-Xmx2048M -cp $LAUNCHER_JAR $LAUNCHER_NAME"

echo "Launching Jack server" $JACK_SERVER_COMMAND

(

Additional knowledge: Try increasing heap size with java option '-Xmx' error resolution when compiling android 7.0

This error occurs because the computer is out of memory. Execute the following three statements on the command line, and then continue compiling

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


Related articles: