Java自学者论坛

 找回密码
 立即注册

手机号码,快捷登录

恭喜Java自学者论坛(https://www.javazxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,会员资料板块,购买链接:点击进入购买VIP会员

JAVA高级面试进阶训练营视频教程

Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程Go语言视频零基础入门到精通Java架构师3期(课件+源码)
Java开发全终端实战租房项目视频教程SpringBoot2.X入门到高级使用教程大数据培训第六期全套视频教程深度学习(CNN RNN GAN)算法原理Java亿级流量电商系统视频教程
互联网架构师视频教程年薪50万Spark2.0从入门到精通年薪50万!人工智能学习路线教程年薪50万大数据入门到精通学习路线年薪50万机器学习入门到精通教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程MySQL入门到精通教程
查看: 706|回复: 0

Android 源码编译及常见错误及解决方法

[复制链接]
  • TA的每日心情
    奋斗
    2024-11-24 15:47
  • 签到天数: 804 天

    [LV.10]以坛为家III

    2053

    主题

    2111

    帖子

    72万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    726782
    发表于 2021-5-29 13:09:39 | 显示全部楼层 |阅读模式

     最近要往arm开发板上移植android系统,大大小小的问题遇到了太多太多,都是泪啊。本人初接触嵌入式开发,对问题的根源不是太了解,不过好在每解决一个问题,便记录一下。话不多说,正式罗列问题:

     

     1 host Executable: a3dconvert (out/host/linux-x86/obj/EXECUTABLES/a3dconvert_intermediates/a3dconvert)
     2 /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libstdc++.so when searching for -lstdc++
     3 /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libstdc++.a when searching for -lstdc++
     4 /usr/bin/ld: cannot find -lstdc++
     5 /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libgcc_s.so when searching for -lgcc_s
     6 /usr/bin/ld: cannot find -lgcc_s
     7 /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.5.4/libgcc.a when searching for -lgcc
     8 /usr/bin/ld: cannot find -lgcc
     9 collect2: ld returned 1 exit status
    10 make: *** [out/host/linux-x86/obj/EXECUTABLES/a3dconvert_intermediates/a3dconvert] Error 

     

    解决方法:
    缺少g++-multilib库,安装即可: apt-get install g++-multilib
    $ sudo apt-get install g++-multilib g++-4.5-multilib


    1 g++: 错误: –fpermissive:没有那个文件或目录
    2 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
    解决方法:
    sudo apt-get install g++-4.4-multilib


    1 rameworks/base/libs/utils/RefBase.cpp: 在成员函数‘void android::RefBase::weakref_type::trackMe(bool, bool)’中:
    2 frameworks/base/libs/utils/RefBase.cpp:483:67: 错误: 将‘const android::RefBase::weakref_impl’作为‘void android::RefBase::weakref_impl::trackMe(bool, bool)’的‘this’实参时丢弃了类型限定 [-fpermissive]
    3 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
    原因:
    Ubuntu 11.10的gcc 4.6版本太高了,android编译需要gcc 4.4
    解决方法:
    更换gcc、g++版本4.6为4.4
    sudo apt-get install gcc-4.4
    sudo apt-get install g++-4.4
    sudo rm -rf /usr/bin/gcc /usr/bin/g++
    sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
    sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++


    1 /usr/bin/ld: cannot find -lz
    2 host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
    3 /usr/bin/ld: cannot find -lz
    4 collect2: ld returned 1 exit status
    5 make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1
    解决方法:
    sudo apt-get install zlib1g-dev
    sudo apt-get install lib64z1-dev


    1 /bin/bash: bison: command not found
    2 Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
    3 bison -d  -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
    4 /bin/bash: bison: command not found
    5 make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
    解决方法:
    sudo apt-get install bison


    1 /bin/bash: flex: command not found
    2 out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In functionint yyparse()’:
    3 out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1827: warning: deprecated conversion from string constant to ‘char*4 out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1970: warning: deprecated conversion from string constant to ‘char*5 Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
    6 /bin/bash: flex: command not found
    7 make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
    解决方法: 
    sudo apt-get install flex


     1 /usr/bin/ld: cannot find -lncurses
     2 host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
     3 /usr/bin/ld: cannot find -lncurses
     4 collect2: ld returned 1 exit status
     5 make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
    解决方法:
    sudo apt-get install libncurses5-dev


    1 fatal error: GL/glx.h: No such file or directory
    2 development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory
    3 compilation terminated.
    4 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 
    解决方法:
    sudo apt-get install libgl1-mesa-dev


    1 sh: gperf: not found
    2 target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables
    3 Generating CSSPropertyNames.h <= CSSPropertyNames.in
    4 sh: gperf: not found
    5 calling gperf failed: 32512 at ./makeprop.pl line 140.
    6 make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25
    7 make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h'

     

    解决方法:
    sudo apt-get install gperf


    1 host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp
    2 frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
    3 frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
    4 make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
    解决方法:
    gedit frameworks/base/libs/utils/Android.mk
    将语句:
    LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
    修改为:
    LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive


    1 out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get':
    2 /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:27: undefined reference to `pthread_getspecific'
    3 out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':
    4 /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create'
    5 /home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific'
    6 collect2: ld returned 1 exit status
    7 make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误 1
    解决方法:
    修改./framework/base/tools/localize/Android.mk文件
    ifeq ($(HOST_OS),linux)
    #LOCAL_LDLIBS += -lrt       把这行注释掉,改为下面一行。
    LOCAL_LDLIBS += -lrt -lpthread
    endif

     

    哎...今天够累的,签到来了1...
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|Java自学者论坛 ( 声明:本站文章及资料整理自互联网,用于Java自学者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2025-1-12 01:39 , Processed in 0.065455 second(s), 30 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表