Android系统编译出错

在Android7.1编译过程中出现如下错误:

专注于为中小企业提供网站设计制作、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业东港免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

Starting
 build with ninjaninja: Entering directory `.' [  0% 8/30301] Ensure 
Jack server is installed and startedJack server already installed in 
"/home/guochongxin/.jack-server"Launching Jack server java 
-XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp 
-Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp 
/home/guochongxin/.jack-server/launcher.jar 
com.android.jack.launcher.ServerLauncher[  0% 10/30301] Building with 
Jack: 
out/target/common/obj/JAVA_LIBRARIES/libprotobuf-java-micro_intermediates/classes.jack[
  0% 12/30301] Building with Jack: 
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dexFAILED:
 /bin/bash 
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex.rspOut
 of memory error (version 1.2-rc4 'Carnac' (298900 
f95d7bdecfceb327f9d201a1348397ed8a843843 by 
android-jack-team@google.com)).GC overhead limit exceeded.Try increasing
 heap size with java option '-Xmx'.Warning: This may have 
produced partial or corrupted output.[  0% 12/30301] Compiling SDK Stubs
 with Jack: 
out/target/comm...AVA_LIBRARIES/android_stubs_current_intermediates/classes.jackninja:
 build stopped: subcommand failed.make: *** [ninja_wrapper] Error 1

从上面的错误提示中可以看到如下一句:

Try increasing heap size with java option '-Xmx'.

按照上述发现的提示语句,我们对prebuilts/sdk/tools/jack-admin文件进行如下修改:1.找到如下语句:

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

2.将上述语句修改为:

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

主要是添加了-Xmx4096m参数,接下来在源码目录下执行如下命令重启jack-admin服务:

./prebuilts/sdk/tools/jack-admin stop-server

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

重启完jack-admin服务后,此时再重新执行编译命令就能编译通过了。

2.android build  Communication error with Jack server (52)

解决方法:

使用命令重新启动jack

jack-admin stop-server

jack-admin start-server

3.如果jack-admin stop-server或者jack-admin start-server失败

1),通过修改配置文件~/.jack-settings,是个隐藏文件,设置不同的端口号:

# Server settings

SERVER_HOST=127.0.0.1

SERVER_PORT_SERVICE=8076

SERVER_PORT_ADMIN=8077

# Internal, do not touch

SETTING_VERSION=4

通过实验发现,单独修改配置文件$HOME/.jack-settings中的端口号没有效果,jack server一直启动失败,提示端口被占用:

com.android.jack.server.api.v01.ServerException: Problem while opening service port

        at com.android.jack.server.JackHttpServer.start(JackHttpServer.java:611)

        at com.android.jack.server.JackServerImpl.run(JackServerImpl.java:62)

        at com.android.jack.launcher.ServerLauncher$3.run(ServerLauncher.java:391)

        at java.lang.Thread.run(Thread.java:745)

Caused by: java.net.BindException: Address already in use

        at sun.nio.ch.Net.bind0(Native Method)

        at sun.nio.ch.Net.bind(Net.java:433)

        at sun.nio.ch.Net.bind(Net.java:425)

        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)

        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)

        at com.android.jack.server.ServerParameters.openSocket(ServerParameters.java:88)

        at com.android.jack.server.ServerParameters.getServiceSocket(ServerParameters.java:67)

        at com.android.jack.server.JackHttpServer.start(JackHttpServer.java:605)

2),需要同时修改 ~/.jack-server/config.properties 中的端口号,方才有效,可以在别的用户启动了jack server的情况再启动另一个jack server,这样就可以实现多用户同时编译,亲测有效:

#Tue Sep 13 17:44:41 CST 2016

jack.server.max-jars-size=104857600

jack.server.max-service=4

jack.server.service.port=8076 

jack.server.max-service.by-mem=1\=2147483648\:2\=3221225472\:3\=4294967296

jack.server.admin.port=8077

jack.server.config.version=2

jack.server.time-out=7200      (修改上面红色这2行,比如改为8086,8087等)

总结一下解决方案就是:

同时修改$HOME/.jack-settings和$HOME/.jack-server/config.properties中的端口号(比如都改为8086/8087),方可支持多用户同时编译.

注:有的可能没有config.properties文件,则需要新建一个config.properties文件

之后使用命令重新启动jack

jack-admin stop-server

jack-admin start-server


当前文章:Android系统编译出错
当前网址:http://scyanting.com/article/ggoihs.html