简体   繁体   English

从 AOSP 源代码树构建 Android 系统应用

[英]Build an Android system app from the AOSP source tree

Is there a way to build an Android system app from AOSP without having to clone the entire code tree and having to build the entire OS?有没有办法从 AOSP 构建 Android 系统应用程序,而不必克隆整个代码树,也不必构建整个操作系统?

Just being able to build the unmodified app from a Linux shell is sufficient, with any toolchain that will do the job.能够从 Linux shell 构建未经修改的应用程序就足够了,任何工具链都可以完成这项工作。 Being able to make modifications in an IDE (Eclipse or Android Studio) is not a requirement (a text editor will do for making changes).不需要能够在 IDE(Eclipse 或 Android Studio)中进行修改(文本编辑器可以进行更改)。

The app in question is CarrierConfig .有问题的应用程序是CarrierConfig Most of the app is just assets, the code consists of just one single Java class (~400 lines of code), but with four internal dependencies not exposed through the SDK API:大多数应用程序只是资产,代码仅包含一个 Java 类(约 400 行代码),但有四个内部依赖项未通过 SDK API 公开:

android.annotation.Nullable
android.os.PersistableBundle.restoreFromXml(XmlPullParser)
android.telephony.TelephonyManager.from(Context)
android.telephony.TelephonyManager#getCarrierIdFromMccMnc(String)

These are what prevents me from simple adding a generic build.gradle and running it through the gradle toolchain.这些是阻止我简单添加通用build.gradle并通过 gradle 工具链运行它的原因。 The build artifact is a simple APK file, with which I would then patch the system image.构建工件是一个简单的 APK 文件,然后我将使用它修补系统映像。

So how would I build this app without needing the entire AOSP source code (just the actual dependencies, and dependencies of dependencies etc.)?那么如何在不需要整个 AOSP 源代码的情况下构建这个应用程序(只是实际的依赖项,以及依赖项的依赖项等)?

Not a complete answer (yet), but some snippets I was able to find out so far:不是一个完整的答案(还),但到目前为止我能够找到一些片段:

Downloading just individual projects from the source tree仅从源代码树下载单个项目

This is what I have been able to piece together from various instructions—untested so far:这是我能够从各种指令拼凑起来的东西——到目前为止未经测试:

mkdir <dir>
cd <dir>
repo init -u <url> -b <branch>
repo sync <project-list>

Where在哪里

( source 1 , source 2 , source 3 , source 4 ) (来源 1 ,来源 2 , 来源 3 ,来源 4 )

Figuring out which repos you need can get tricky, and if your dependencies have further dependencies, this can become a time-comsuming process.弄清楚您需要哪些存储库可能会很棘手,如果您的依赖项有更多的依赖项,这可能会成为一个耗时的过程。

Also I haven't figured out if the next step actually works with a source tree stripped down in this manner.此外,我还没有弄清楚下一步是否真的适用于以这种方式剥离的源代码树。

Building individual projects构建个人项目

If you just need to build a single project, you can use mmm for that:如果您只需要构建一个项目,您可以使用mmm来实现:

. build/envsetup.sh
lunch
mmm path/to/the/project/

( source ) 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM