因为科研需要,我最近在编译Android源码,其间遇到的一些问题记录下来,以备日后查阅。
Android 6
Installing OpenJDK 7
AOSP only accepts OpenJDK 7 as compiling Java version. No HotSpot (Oracle JDK).
http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=477645
Install via PPA.
1 | sudo add-apt-repository ppa:openjdk-r/ppa |
bison: No such file or directory
Error message:
1 | /bin/bash: prebuilts/misc/linux-x86/bison/bison: No such file or directory |
Solution:
1 | sudo apt-get install bison |
Link error
Error message:
1 | clang: error: linker command failed with exit code 1 (use -v to see invocation) |
解决方法:修改文件 art/build/Android.common_build.mk
1 | diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk |
另一种解决方法:修改文件 art/build/Android.common_build.mk
1 | diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk |
来源:https://blog.csdn.net/cnliwy/article/details/52189349
Android 7
OpenJDK 8
删除 openjdk-7-jre,安装 openjdk-8-jre。
Out of memory
Error message:
1 | [ 34% 12315/35670] Building with Jack: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/with-local/classes.dex |
Solution:
1 | diff --git prebuilts/sdk/tools/jack-admin prebuilts/sdk/tools/jack-admin |
重启jack-admin
1 | ./prebuilts/sdk/tools/jack-admin stop-server |