Android7.0~8.1编译过程中可能会出现异常报错,这里对其中一种情况做出分析和解决方案的展示。
/data/androidSource/lowerVersion/android-7.1.2_r8$ java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-8u362-ga-0ubuntu1~18.04.1-b09)
OpenJDK 64-Bit Server VM (build 25.362-b09, mixed mode)
avl-ops@fix-patch:/data/androidSource/lowerVersion/android-7.1.2_r8$ make -j2
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=7.1.2
TARGET_PRODUCT=aosp_marlin
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=krait
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.15.0-171-generic-x86_64-with-Ubuntu-18.04-bionic
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=N2G47O
OUT_DIR=out
============================================
Running kati to generate build-aosp_marlin.ninja...
No need to regenerate ninja file
Starting build with ninja
ninja: Entering directory `.'
[ 0% 8/34359] 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 jack prebuilts/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 )"
Jack server already installed in "/home/avl-ops/.jack-server"
Communication error with Jack server (35), try 'jack-diagnose' or see Jack server log
SSL error when connecting to the Jack server. Try 'jack-diagnose'
SSL error when connecting to the Jack server. Try 'jack-diagnose'
[ 0% 8/34359] target StaticExecutable: healthd (out/target/product/marlin/obj/EXECUTABLES/healthd_intermediates/LINKED/healthd)
ninja: build stopped: subcommand failed.
build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
#### make failed to build some targets (33 seconds) ####
该问题大部分原因都是端口占用导致。
多用户场景下的端口占用参考:https://www.cnblogs.com/blogs-of-lxl/p/11589521.html
单用户可以参考下面的处理方式
根绝报错提示运行"jack-diagnose"
android-7.1.2_r8/prebuilts/sdk/tools$ jack-diagnose
error: process ID list syntax error
Usage:
ps [options]
Try 'ps --help '
or 'ps --help '
for additional help text.
For more details see ps(1).
Port 8077 is used by another process (pid=), please ensure to free the port or change port configuration in '/home/weiqing/.jack-settings' and '/home/weiqing/.jack-server/config.properties'
error: process ID list syntax error
Usage:
ps [options]
Try 'ps --help '
or 'ps --help '
for additional help text.
For more details see ps(1).
Port 8076 is used by another process (pid=), please ensure to free the port or change port configuration in '/home/weiqing/.jack-settings' and '/home/weiqing/.jack-server/config.properties'
Connection to 10.251.1.212 closed.
由提示"Port 8076 is used by another process (pid=),"可知端口被占用。
在android源码根目录中执行下面命令,先杀掉服务
cd /prebuilts/sdk/tools/
./jack-admin kill-server
# 1
vim /etc/java-8-openjdk/security/java.security
原始文件目标文件:
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
include jdk.disabled.namedCurves
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
# 2
从jdk.tls.disabledAlgorithms中删除TLSv1, TLSv1.1
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
include jdk.disabled.namedCurves
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
cd /prebuilts/sdk/tools/
./jack-admin kill-server
./jack-admin start-server
参考:https://blog.csdn.net/m0_37910557/article/details/116701908?spm=1001.2014.3001.5502