android 8 sdk源码编译时报错Try increasing heap size with java option '-Xmx'

编译SDK时,输出如下错误

Out of memory error (version 1.3-rc6 'Douarn' (441800 22a11d4b264ae70e366aed3025ef47362d1522bb by [email protected])).
GC overhead limit exceeded.
Try increasing heap size with java option '-Xmx'

解决方案

方法一

1.设置环境变量(设置Android编译器能使用的最大内存为4G)

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"

2.然后执行jack重启命令:

out/host/linux-x86/bin/jack-admin kill-server
out/host/linux-x86/bin/jack-admin start-server

方法二

1.vi prebuilts/sdk/tools/jack-admin

对JACK_SERVER_COMMAND增加-Xmx4096m选项,具体如下

修改前:

JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -cp $LAUNCHER_JAR $LAUNCHER_NAME"

修改后:
JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -Xmx4096m -cp $LAUNCHER_JAR $LAUNCHER_NAME"

2.然后执行jack重启命令:

out/host/linux-x86/bin/jack-admin kill-server
out/host/linux-x86/bin/jack-admin start-server

你可能感兴趣的:(Android)