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中标记的全部源码

相关推荐
androidwork41 分钟前
Android LinearLayout、FrameLayout、RelativeLayout、ConstraintLayout大混战
android·java·kotlin·androidx
每次的天空43 分钟前
Android第十三次面试总结基础
android·面试·职场和发展
wu_android1 小时前
Android 相对布局管理器(RelativeLayout)
android
李斯维3 小时前
循序渐进 Android Binder(二):传递自定义对象和 AIDL 回调
android·java·android studio
androidwork3 小时前
OkHttp 3.0源码解析:从设计理念到核心实现
android·java·okhttp·kotlin
像风一样自由3 小时前
【001】frida API分类 总览
android·frida
casual_clover4 小时前
Android 之 kotlin 语言学习笔记四(Android KTX)
android·学习·kotlin
移动开发者1号5 小时前
Android 大文件分块上传实战:突破表单数据限制的完整方案
android·java·kotlin
移动开发者1号5 小时前
单线程模型中消息机制解析
android·kotlin
每次的天空8 小时前
Android第十五次面试总结(第三方组件和adb命令)
android