使用 Android Studio 开发 AOSP [英] Developing AOSP with Android Studio

查看:41
本文介绍了使用 Android Studio 开发 AOSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个开发环境以对 AOSP 源代码进行一些自定义修改,并希望使用 Android Studio 作为我的 IDE.然而,在完成必要的步骤之后,Android Studio 似乎无法识别某些类和方法.我做错什么了吗?这是我所做的简要说明:

I'm trying to setup a development environment to do some custom modifications on the AOSP source code, and would like to use Android Studio as my IDE. After doing the necessary steps, however, Android Studio seems to not be able to recognize some of the classes and methods. Did I do something wrong? Here's a rundown of what I did:

我按照官方文档为克隆和构建AOSP做了必要的准备(依赖等).之后,我用 repo 克隆了 AOSP 7.1.1-r11 分支,然后运行以下命令:

I did the necessary preparations (dependencies, etc.) for cloning and building AOSP according to the official documentation. After that, I cloned the AOSP 7.1.1-r11 branch with repo, and then ran the following commands:

$ source build/envsetup.sh
$ lunch aosp_arm-eng
$ make
$ mmm development/tools/idegen/
$ development/tools/idegen/idegen.sh

make 花了我大约一个小时,运行 idegen.sh 花了我大约 5 秒.

The make took me about an hour, running the idegen.sh took me around 5 seconds.

idegen.sh 生成了一个 android.ipr 文件,我在 Android Studio 中成功导入了该文件.当提示选择 SDK 时,我选择了 openjdk 1.8.0_121 并删除了类路径中的所有库,如 idegen 自述文件中所示.

The idegen.sh generated an android.ipr file which I successfully imported in Android Studio. When prompted with an SDK selection, I selected openjdk 1.8.0_121 and removed all the libraries in the classpath, as indicated in the idegen readme file.

在让 Android Studio 运行初始导入操作后,我继续从电话框架中打开 PhoneFactory.java,我要在其中进行修改.这就是我的问题所在:有几十个方法是红色的(无法解决).

After letting Android Studio run the initial import actions, I went ahead and opened the PhoneFactory.java from the telephony framework where I want to do my modifications. Here is where I have my problem: several dozen methods are in red (cannot be resolved).

我确信我克隆 AOSP 的方式没有问题,因为 make 正确通过.有什么想法吗?

I am sure there is no problem with how I cloned AOSP, as the make passes correctly. Any ideas?

推荐答案

我总是使用这些步骤没有任何问题:

I always use these steps without any problem at all:

https://shuhaowu.com/blog/setting_up_intellij_with_aosp_development.html

您的问题最重要的部分是:

The most important parts for your problem are:

  • 设置没有库的 SDK
  • 在项目结构 -> 模块 -> 删除所有以 .jar 结尾的依赖
  • 作为奖励:转到源"选项卡并浏览到 out/target/common/R.右键单击它并单击源

在链接中,您可以看到可以使步骤更容易遵循的屏幕截图.

In the link you can see screenshots that can make the steps easier to follow.

这篇关于使用 Android Studio 开发 AOSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆