ubuntu 15.10 64bit构建Android源5.0版

时间:2016-04-14 09:28:08

标签: android linux ubuntu android-source

如何修复此问题?当我用5.0构建Android源代码时 'make -j4',它造成了问题。 这是错误日志:

Install: out/host/linux-x86/bin/acp
Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
prebuilts/misc/linux-x86/bison/bison -d  -o out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/content/EventLogTags.java <= frameworks/base/core/java/android/content/EventLogTags.logtags
prebuilts/misc/linux-x86/bison/bison: m4 子进程失败
build/core/binary.mk:539: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp' failed
make: *** [out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 1
make: *** 正在等待未完成的任务....
frameworks/base/tools/aidl/aidl_language_l.l:55: warning, 无法匹配规则
flex-2.5.39: fatal internal error, exec of /usr/bin/m4 failed
build/core/binary.mk:576: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' failed
make: *** [out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 1
make: *** Deleting file 'out/host/linux-x86/obj32/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp'
logtags: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/speech/tts/EventLogTags.java <= frameworks/base/core/java/android/speech/tts/EventLogTags.logtags

2 个答案:

答案 0 :(得分:2)

仔细检查您是否安装了所有必需的软件包https://source.android.com/source/initializing.html

答案 1 :(得分:1)

就我而言,在Ubuntu 18.04中构建棉花糖6.0.1_r1时遇到类似的错误。

如果您遇到类似的错误:

build/core/binary.mk:646: recipe for target 'out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp' failed
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Aborted (core dumped)

仔细查看该行,它是一个core dumped,所以我使用coredumpctl list,用 G 导航到列表末尾,然后找出核心转储执行的路径(右列)为prebuilts/misc/linux-x86/flex/flex-2.5.39

PREBUILT文件显示:

xb@dnxb:~/my_android_src/prebuilts/misc/linux-x86/flex$ cat PREBUILT 
The objects in this prebuilt directory can be rebuilt
using the source archive hosted at

http://sourceforge.net/projects/flex/files/

Commands:

./configure
make CFLAGS="-static" LDFLAGS="-static"
# (Disregard the errors at the end of the build)
rm flex
make CFLAGS="-static" LDFLAGS="-static" flex
# Copy the linker command line, replace it with static libm.a
gcc  -static  -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o  /usr/lib/x86_64-linux-gnu/libm.a
xb@dnxb:~/my_android_src/prebuilts/misc/linux-x86/flex$ 

就是这样,前两行说如果发生错误,您可能需要重新构建自己,因为此flex-2.5.39二进制文件是在另一个平台上预构建的。

因此只需解压缩该目录的flex-2.5.39.tar.gz,转到解压缩的flex-2.5.39目录,然后按照上面的PREBUILT指令进行操作。

简而言之,您需要执行以下步骤:

    cd <ANDROID_TREE_DIR>/prebuilts/misc/linux-x86/flex
    tar -zxvf flex-2.5.39.tar.gz
    cd flex-2.5.39
    make CFLAGS="-static" LDFLAGS="-static"
    rm flex
    make CFLAGS="-static" LDFLAGS="-static" flex
    /bin/bash ./libtool --tag=CC   --mode=link gcc  -static  -static -o flex ccl.o dfa.o ecs.o scanflags.o gen.o main.o misc.o nfa.o parse.o scan.o skel.o sym.o tblcmp.o yylex.o options.o scanopt.o buf.o tables.o tables_shared.o filter.o regex.o lib/libcompat.la /usr/lib/x86_64-linux-gnu/libm.a
    cd ..
    cp flex-2.5.39/flex .
    mv flex flex-2.5.39
    ls -la 
        flex-2.5.39 #### <<- YOUR new generated file
        flex-2.5.39.tar.gz
        MODULE_LICENSE_BSD_LIKE
        NOTICE
        PREBUILT

现在尝试再次执行make <module> -j4,不再因此类错误而中止。

p / s:如果看到类似LANG=C make pm -j4的错误消息,则可以使用LC_*替代方式。

p / s2:我还需要以下符号链接ld来固定'out/host/linux-x86/obj/lib/libart.so' failederror: unsupported reloc 42

xb@dnxb:~/my_android_src$ cp prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld ../ld_bk #backup android source's ld first
xb@dnxb:~/my_android_src$ rm prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld #remove android source's ld
xb@dnxb:~/my_android_src$ ln -s /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8//x86_64-linux/bin/ld #create symlink for android source's ld to system's ld.gold