简体   繁体   English

使用Android Studio开发AOSP

[英]Developing AOSP with 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. 我正在尝试设置开发环境,对AOSP源代码进行一些自定义修改,并希望使用Android Studio作为我的IDE。 After doing the necessary steps, however, Android Studio seems to not be able to recognize some of the classes and methods. 但是,在执行必要的步骤后,Android Studio似乎无法识别某些类和方法。 Did I do something wrong? 我做错什么了吗? Here's a rundown of what I did: 这是我所做的事情的简要说明:

I did the necessary preparations (dependencies, etc.) for cloning and building AOSP according to the official documentation. 我根据官方文档为克隆和构建AOSP做了必要的准备工作(依赖性等)。 After that, I cloned the AOSP 7.1.1-r11 branch with repo, and then ran the following commands: 之后,我用repo克隆了AOSP 7.1.1-r11分支,然后运行以下命令:

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

The make took me about an hour, running the idegen.sh took me around 5 seconds. 制作花了我大约一个小时,运行idegen.sh花了我大约5秒钟。

The idegen.sh generated an android.ipr file which I successfully imported in Android Studio. idegen.sh生成了一个android.ipr文件,我在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. 当提示选择SDK时,我选择了openjdk 1.8.0_121并删除了类路径中的所有库,如idegen自述文件中所示。

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. 在让Android Studio运行初始导入操作后,我继续从电话框架中打开PhoneFactory.java,我想在其中进行修改。 Here is where I have my problem: several dozen methods are in red (cannot be resolved). 这是我遇到问题的地方:几十种方法都是红色的(无法解决)。

I am sure there is no problem with how I cloned AOSP, as the make passes correctly. 我确信克隆AOSP的方式没有问题,因为make正确传递了。 Any ideas? 有任何想法吗?

I always use these steps without any problem at all: 我总是毫无问题地使用这些步骤:

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

The most important parts for your problem are: 您问题最重要的部分是:

  • Set the SDK with no libraries 设置SDK没有库
  • In the Project Structure -> Module -> Remove all of the dependencies that ends with a .jar 在项目结构 - >模块 - >删除所有以.jar结尾的依赖项
  • As a bonus: go to the Sources tab and browse to out/target/common/R. 作为奖励:转到“来源”选项卡并浏览到/ target / common / R. Right click on it and click Source 右键单击它,然后单击“源”

In the link you can see screenshots that can make the steps easier to follow. 在链接中,您可以看到可以使步骤更容易理解的屏幕截图。

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

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