AOSP开发环境配置

AOSP开发环境配置

一. 工具软件安装

1. 安装git:

  • sudo apt install git

2. 安装依赖工具

  • sudo apt install git-core libssl-dev libffi-dev gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g+±multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev libz-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip

3. 下载与安装Python3

4. 软件版本管理工具

  • 配置update-alternatives

    • sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2

    • sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 3

  • 选择Python版本

    • sudo update-alternatives --config python

二. AOSP源码下载

1. AOSP官方地址:https://source.android.google.cn/setup/build/downloading

2. 中科大镜像:https://mirrors.ustc.edu.cn/help/aosp.html

3. 清华镜像:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/

三. 编译 aosp 代码

. build/envsetup.sh

lunch aosp_x86_64-eng(问题:模拟器镜像无法生成)

lunch sdk_x86_64 手机

lunch sdk_car_x86_64-userdebug 车载

  • 选择的lunch sdk_x86_64 用于使用模拟器

make

复制代码
- 编译完成(4个小时左右)
  • 常见问题

    • 磁盘空间不足

      • df -h 查看磁盘使用情况

emulator

  • 打开模拟器

    • 虚拟机嵌套虚拟机问题

      • windows下安装vmware里边嵌套kvm提示kvm不可用解决办法:
        步骤:虚拟机-设置-处理器-勾选虚拟化Intel-确认
    • 模拟器镜像无法生成

      • lunch sdk_x86_64

      • Lunch menu路径

        • build/make/target/product/AndroidProducts.mk
    • 编译后的模拟器路径

      • out/target/product/emulator_x86_64
  • 日志查看

    • adb shell

    • logcat -c

      logcat

      logcat -s TAG

    • 查找文件

      find -name 文件名

      查找文件内容:方法调用

      grep "文件内容" ./ -rn

    • 打印调用栈

      Log.i(TAG,"oncreate",new Exception());

四. android studio安装与源码导入

1. 安装jdk

  • sudo apt install openjdk-9-jre-headless

2. 安装as

  • https://developer.android.google.cn/studio

    • android-studio-2022.1.1.21-linux.tar.gz
  • 回到源码目录

    执行

    make idegen -j4

  • sudo development/tools/idegen/idegen.sh

    • 生成文件android.iml & android.ipr
  • 导入源码前建议

    • AS的bin目录下,修改studio64.vmoptions增加内存

3. AS启动与源码导入

  • 先进入bin目录 cd bin

    执行 ./studio.sh

  • AS下File->open->android.ipr

    即可导入android.iml中标记的全部源码

相关推荐
fatsheep洋6 分钟前
文件上传 --- uploadlabs靶场
android
雨白9 小时前
Android 自定义 View:从绘制基础到实战仪表盘与饼图
android
jiunian_cn9 小时前
【Linux】线程
android·linux·运维·c语言·c++·后端
Frank_HarmonyOS18 小时前
Android MVVM(Model-View-ViewModel)架构
android·架构
新子y1 天前
【操作记录】我的 MNN Android LLM 编译学习笔记记录(一)
android·学习·mnn
lincats1 天前
一步一步学习使用FireMonkey动画(1) 使用动画组件为窗体添加动态效果
android·ide·delphi·livebindings·delphi 12.3·firemonkey
想想吴1 天前
Android.bp 基础
android·安卓·android.bp
写点啥呢1 天前
Android为ijkplayer设置音频发音类型usage
android·音视频·usage·mediaplayer·jikplayer
coder_pig1 天前
🤡 公司Android老项目升级踩坑小记
android·flutter·gradle
死就死在补习班2 天前
Android系统源码分析Input - InputReader读取事件
android