Android7.0(也就是Android N)上默認使用JACK編譯器而不再使用openjdk了寝受,但發(fā)現(xiàn)JACK不是很好用,比如最大的一個問題就是堕花,同一臺linux服務器上不允許不同用戶同時進行andorid7.0的編譯术瓮,原因就是后面開始編譯的用戶無法正常啟動jack server,而jack server居然不能關閉冰更,雖然JACK文檔中有說提供一些宏,只要設置宏為對應的值就可以關閉昂勒,但實測發(fā)現(xiàn)無效蜀细,關閉不了,這個蛋痛的問題戈盈,搞了2天奠衔,不過總算有方法可以搞定,下面是我對多用戶無法同時編譯的問題的解決過程(最下面有解決方案奕谭,):
1涣觉,嘗試關閉JACK,但發(fā)現(xiàn)失斞:
1)官册,當在板型目錄中的BoardConfig.mk中添加ANDROID_COMPILE_WITH_JACK:=false時,編譯會出錯:
ninja: error: 'out/target/common/obj/APPS/ActSensorCalib_intermediates/with-local/classes.dex', needed by 'out/target/common/obj/APPS/ActSensorCalib_intermediates/classes.dex', missing and no known rule to make it
make[1]: *** [ninja_wrapper] Error 1
2)难捌,當在板型目錄中的BoardConfig.mk中添加DEFAULT_JACK_ENABLED := disabled時膝宁,仍然不能關閉JACK,都會報錯:
[ 34% 13188/37803] Ensure Jack server is installed and started
FAILED: /bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar? 2>&1 || (exit 0) ) &&
(JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8 -XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) &&
(prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 4.8.ALPHA 2>&1 || exit 0 ) &&
(prebuilts/sdk/tools/jack-admin update jackprebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47;
prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47;
prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )"
Writing client settings in /home/test/.jack-settings
Installing jack server in "/home/test/.jack-server"
Communication error with Jack server (58), try 'jack-diagnose' or see Jack server log
Failed to contact Jack server: Problem reading /home/test/.jack-server/client.pem. Try 'jack-diagnose'
Failed to contact Jack server: Problem reading /home/test/.jack-server/client.pem. Try 'jack-diagnose'
[ 34% 13188/37803] Compiling SDK Stubs...tubs_current_intermediates/classes.jar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
[ 34% 13188/37803] target SharedLib: l...bLLVM_intermediates/LINKED/libLLVM.so)
ninja: build stopped: subcommand failed.
make[1]: *** [ninja_wrapper] Error 1
make[1]: Leaving directory `/home/test/700E/android/android'
3)根吁,嘗試通過設置ANDROID_FORCE_JACK_ENABLED := disabled來進行關閉JACK 员淫,編譯也報錯,跟1)一樣的錯誤:
ninja: warning: multiple rules generate out/target/product/s900_RY_VR/system/xbin/su. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: error: 'out/target/common/obj/APPS/ActSensorCalib_intermediates/with-local/classes.dex', needed by 'out/target/common/obj/APPS/ActSensorCalib_intermediates/classes.dex', missing and no known rule to make it
make[1]: *** [ninja_wrapper] Error 1
2击敌,嘗試解決介返,網(wǎng)上有很多人反映這個問題,但是目前沒有有效的解決方案沃斤,最可能的辦法是從2個方面嘗試:
1)圣蝎,這個issue有人說是需要增加RAM:I was on VitualMachine when I had the error. And the fix was to increase the RAM,不過他是在虛擬機上衡瓶,我們的應該跟RAM無關徘公;
2),通過修改配置文件$HOME/.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
通過實驗發(fā)現(xiàn)关面,單獨修改配置文件$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)
3)等太,需要同時修改 $HOME/.jack-server/config.properties 中的端口號,方才有效蛮放,可以在別的用戶啟動了jack server的情況再啟動另一個jack server澈驼,這樣就可以實現(xiàn)多用戶同時編譯,親測有效:
#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? ? ? (修改jack.server.service.port=8076 和jack.server.admin.port=8077這2行筛武,比如改為8086缝其,8087等)
總結一下解決方案就是:
同時修改$HOME/.jack-settings和$HOME/.jack-server/config.properties中的端口號(比如都改為8086/8087)挎塌,方可支持多用戶同時編譯。
目前可以先用這個方法解決問題内边。
補充一下后來編譯遇到的錯誤的解決方法:
錯誤提示:
[ 8% 1/12] Ensure Jack server is installed and started
再試了一次還是報錯:
FAILED:/bin/bash -c "(prebuilts/sdk/tools/jack-admin install-serverprebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar2>&1 || (exit 0) ) &&(JACK_SERVER_VM_ARGUMENTS=\"-Dfile.encoding=UTF-8-XX:+TieredCompilation\" prebuilts/sdk/tools/jack-admin start-server2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin updateserver prebuilts/sdk/tools/jack-server-4.8.ALPHA.jar 4.8.ALPHA 2>&1 ||exit 0 ) && (prebuilts/sdk/tools/jack-admin update jackprebuilts/sdk/tools/jacks/jack-2.28.RELEASE.jar 2.28.RELEASE || exit 47;prebuilts/sdk/tools/jack-admin update jackprebuilts/sdk/tools/jacks/jack-3.36.CANDIDATE.jar 3.36.CANDIDATE || exit 47;prebuilts/sdk/tools/jack-admin update jackprebuilts/sdk/tools/jacks/jack-4.7.BETA.jar 4.7.BETA || exit 47 )"
Jack server already installed in"/home/local/ACTIONS/songzhining/.jack-server"
Launching Jack server java -XX:MaxJavaStackTraceDepth=-1 -Djava.io.tmpdir=/tmp-Dfile.encoding=UTF-8 -XX:+TieredCompilation -cp/home/local/ACTIONS/songzhining/.jack-server/launcher.jarcom.android.jack.launcher.ServerLauncher
Jack server failed to (re)start, try 'jack-diagnose' or see Jack server log
No Jack server running. Try 'jack-admin start-server'
No Jack server running. Try 'jack-admin start-server'
ninja: build stopped: subcommand failed.
make[1]: *** [ninja_wrapper] Error 1
解決方案:
通過查看文件 $HOME/.jack-server/logs/jack-server-0-0.log:
10:26:40.898:SEVERE: com.android.jack.launcher.ServerLauncher: Server 1 Exception
com.android.jack.server.api.v01.ServerException: './config.properties' musthave permission rw------- but have rwx------
? atcom.android.jack.server.JackServerImpl.run(JackServerImpl.java:65)
? atcom.android.jack.launcher.ServerLauncher$3.run(ServerLauncher.java:391)
? atjava.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: './config.properties' must have permissionrw------- but have rwx------
? at com.android.jack.server.JackHttpServer.checkAccess(JackHttpServer.java:696)
? atcom.android.jack.server.JackHttpServer.loadConfig(JackHttpServer.java:513)
? atcom.android.jack.server.JackHttpServer.<init>(JackHttpServer.java:379)
? at com.android.jack.server.JackServerImpl.run(JackServerImpl.java:61)
? ... 2 more
發(fā)現(xiàn)是配置文件的權限不對造成的榴都,把文件$HOME/.jack-server/config.properties的權限由rwx改為rw即可解決問題。