您好,登錄后才能下訂單哦!
在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<size>'.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<size>'.
按照上述發現的提示語句,我們對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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。