zoukankan      html  css  js  c++  java
  • Android aosp编译和运行

    1 环境准备

    首先需要准备一台Linux服务器,笔者偏好CentOS,不过Google官方建议是Ubuntu;这里不具体列举需要安装的软件。

    2 源码下载

    2.1 repo工具

    # mkdir ~/bin
    # PATH=~/bin:$PATH
    # curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    # chmod a+x ~/bin/repo

    2.2 aosp下载

    因为国内被墙的原因,通常会通过国内镜像源的方式来下载(以11.0.0_r40版本为例)

    2.2.1 直接下载

    # repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r40
    # repo sync -j64

    2.2.2 基础包下载

    # wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar
    # tar xf aosp-latest.tar
    # repo init -b android-11.0.0_r40
    # repo sync -j64

    3 编译和运行

    3.1 编译

    # cd aosp
    # source build/envsetup.sh
    # lunch aosp_car_x86_64-userdebug
    # m

    3.2 运行

    这里是在编译的服务器上直接运行,笔者尝试过在Windows上来运行,但是不成功

    # cd aosp
    # source build/envsetup.sh
    # lunch aosp_car_x86_64-userdebug
    # emulator      // 运行模拟器
    # adb emu kill  // 关闭模拟器

    4 有用的信息

    4.1 aosp版本号确认

    # cat build/make/core/build_id.mk
    BUILD_ID=RQ3A.210805.001.A1

    然后参考<AOSP源代码标记>找到对应的buildid即可知道具体aosp版本号

    4.2 Android Studio查看aosp源码

    首先通过如下命令生成AS工程文件android.iml和android.ipr

    # cd aosp
    # source build/envsetup.sh
    # lunch aosp_car_x86_64-userdebug
    # mmm development/tools/idegen/
    # development/tools/idegen/idegen.sh

    由于aosp源码量太大,可以通过修改android.iml中excludeFolder属性来排除不关心的目录(也可以在生成工程文件前通过修改development/tools/idegen/excluded-paths来实现)

    最后通过AS打开android.ipr即可打开aosp工程来浏览源码

    参考:
    <Android开发者Codelab>
    <Tsinghua Android镜像使用帮助>
    <LineageOS Build for instantnoodle>
    <使用Android Studio导入AOSP源码的奇技淫巧>

  • 相关阅读:
    增加网站内容步骤
    简单使用
    dedecms的讲解 要求
    shop34-3-自动加载实现
    shop34-2-运转-平台分发
    shop34-1-目录布局
    match_controller
    match_model
    match_mvc
    laravel 路由
  • 原文地址:https://www.cnblogs.com/hzl6255/p/15612883.html
Copyright © 2011-2022 走看看