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

相关推荐
黄林晴5 小时前
Android17 为什么重写 MessageQueue
android
阿巴斯甜1 天前
Android 报错:Zip file '/Users/lyy/develop/repoAndroidLapp/l-app-android-ble/app/bu
android
Kapaseker1 天前
实战 Compose 中的 IntrinsicSize
android·kotlin
xq95271 天前
Andorid Google 登录接入文档
android
黄林晴1 天前
告别 Modifier 地狱,Compose 样式系统要变天了
android·android jetpack
冬奇Lab2 天前
Android触摸事件分发、手势识别与输入优化实战
android·源码阅读
城东米粉儿2 天前
Android MediaPlayer 笔记
android
Jony_2 天前
Android 启动优化方案
android
阿巴斯甜2 天前
Android studio 报错:Cause: error=86, Bad CPU type in executable
android
张小潇2 天前
AOSP15 Input专题InputReader源码分析
android