Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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:

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

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

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.

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).

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

like image 647
Alexis Sorokine Avatar asked Feb 08 '17 10:02

Alexis Sorokine


1 Answers

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:

  • Set the SDK with no libraries
  • In the Project Structure -> Module -> Remove all of the dependencies that ends with a .jar
  • As a bonus: go to the Sources tab and browse to out/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.

like image 85
Olaia Avatar answered Sep 22 '22 13:09

Olaia