下载源码:解决方案 https://blog.csdn.net/letmefish/article/details/80845142 我这里除了这句话出错外其它没错: 这样报错 repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest 这样不报错直接下 repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-8.1.0_r13 报连接不了谷歌:解决方案 https://mirror.tuna.tsinghua.edu.cn/help/AOSP/ 或者直接墙***:没钱用可以用火狐插件: hoxx 报邮箱错:解决方案 https://blog.csdn.net/deng0zhaotai/article/details/28879347 下载完成 安装依赖 (根据平台而定官网有给出) ubuntu 12.04
sudo apt-get install git-core gnupg flex bison gperf build-essential
sudo apt-get install zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386
sudo apt-get install libreadline6-dev:i386 libgl1-mesa-dev:i386 g++-multilib mingw32 openjdk-6-jdk tofrodos
sudo apt-get install python-markdown libxml2-utils xsltproc zlib1g-dev:i386
编译
报host SharedLib: lib64EGL_translator (out/host/linux-x86/obj/lib/lib64EGL_translator.so)libGL.so库错误 (这里要注意是多少位的编译 32 位的要用 32 位的库)
要安装依赖
如果不行 先到盘里找看有无libGL库 有设置软连接如:sudo ln -s /lib/i386-linux-gnu/libGL.so.1.2.0 /usr/lib/libGL.so
也可以这样搜:
apt-file search libGL.so
找到是那个安装包里含有,然后apt-get install package
需要先 #apt-get install apt-file #apt-file update
还是不行报没有定义'xxxxxxx' 那就: sudo apt-get install -y steam https://www.linuxidc.com/Linux/2013-04/82816.htm 报内存不足:g++: internal compiler error: Killed (program cc1plus)
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
主要原因大体上是因为内存不足,有点坑 临时使用交换分区来解决吧
sudo dd if=/dev/zero of=/swapfile bs=1024M count=16
sudo mkswap /swapfile
sudo swapon /swapfile
After compiling, you may wish to
Code:
sudo swapoff /swapfile
sudo rm /swapfile
报external/llvm/lib/ExecutionEngine/JIT/Intercept.cpp:69:67: error: ‘lseek64’ was not declared in this scope 去对应文件添加头文件:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
报error:reference 'counts' cannot be declared 'mutable'
In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0:
external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1
解决办法:
external/oprofile/libpp/format_output.h
把:
mutable counts_t & counts;
改为:
counts_t & counts;
home/android/workspace/buildroid/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
解决了,
解决方法:
解决办法:
vim external/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread -ldl
external/llvm/include/llvm/Constants.h: In static member function ‘static llvm::Constant llvm::ConstantExpr::getGetElementPtr(llvm::Constant, llvm::Constant const, unsigned int, bool)’:
external/llvm/include/llvm/Constants.h:793:41: error: cast from type ‘llvm::Constant const’ to type ‘llvm::Value’ casts away qualifiers [-Werror=cast-qual]
return getGetElementPtr(C, (Value)IdxList, NumIdx, InBounds);
^
cc1plus: all warnings being treated as errors
make: [out/host/linux-x86/obj/STATIC_LIBRARIES/libslang_intermediates/slang_backend.o] Error 1
make: Waiting for unfinished jobs....
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libslang_intermediates/slang.o] Error 1
Fix:
vi frameworks/compile/slang/Android.mk
Remove '-Werror' from line 22:
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
错误:
external/gtest/src/../include/gtest/gtest-param-test.h:1185:28: required from here external/gtest/src/../include/gtest/internal/gtest-param-util-generated.h:77:26: error: ‘ValuesIn’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] return ValuesIn(array);
解决办法:
将文件/external/gtest/src/Android.mk中所有的”LOCAL_CFLAGS += -O0”修改为”LOCAL_CFLAGS += -O0 -fpermissive”
其它遇到的错误这里可以解决一些:
https://blog.csdn.net/hongbochen1223/article/details/47708233
https://blog.csdn.net/deng0zhaotai/article/details/37034105
https://www.linuxidc.com/Linux/2014-03/97628.htm
编译成功后会出现 3 个 img文件在(out/target/product/generic)
配置相关环境变量 把out/target/product/generic 与/out/host/linux-x86/bin添加到环境变量
到out 同级目录
输入:
source build/envsetup.sh
lunch 选择你开始编译的那个选项
cd 到 img 目录
运行 android
root@ubuntu:~/out/target/product/generic# cd -
/root
root@ubuntu:~# source build/envsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/tuna/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
root@ubuntu:~#
root@ubuntu:~# lunch
You're building on Linux
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. vbox_x86-eng
4. full_maguro-userdebug
5. full_tuna-userdebug
6. full_panda-eng
Which would you like? [full-eng] 2
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.1
TARGET_PRODUCT=full_x86
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
TARGET_ARCH_VARIANT=x86-atom
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ITL41D
============================================
root@ubuntu:~# emulator
emulator: ERROR: No initial system image for this configuration!
root@ubuntu:~# cd -
/root/out/target/product/generic
root@ubuntu:~/out/target/product/generic# emulator -system system.img -data userdata.img -ramdisk ramdisk.img
emulator: WARNING: system partition size adjusted to match image file (163 MB > 66 MB)
等下就会运行完: 如果要配置 ajva 环境的话:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
https://www.jianshu.com/p/9bf96f648884 https://blog.csdn.net/fuchaosz/article/details/51487585/ https://blog.csdn.net/dl6655/article/details/78869501 https://blog.csdn.net/loongembedded/article/details/79406435 注意内存问题 虚拟机 100g 左右 物理机至少 有120 g 反正吃了我 90 多g