ubuntu 15.10 64bit构建Android源5.0版

问题描述 投票:-3回答:2

我该如何解决这个问题?当我使用'make -j4'构建5.0的Android源代码时,它会导致问题。这是错误日志:

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
android linux ubuntu android-source
2个回答
2
投票

仔细检查你已经安装了所有必需的包https://source.android.com/source/initializing.html


1
投票

在我的情况下,我在Ubuntu 18.04中构建Marshmallow 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:我还需要symlink 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
© www.soinside.com 2019 - 2024. All rights reserved.