Search code examples
androidintellij-ideaandroid-source

AOSP PackageManagerService referencing Roboelectric and therefore does not compile


I built AOSP 5.1.0_r3 and imported into IntelliJ. And followed these steps.

But When I open for example PackageManagerService.java code its not able to compile and its referencing external/robolectric/lib/main/android.jar/android/os/Process. For example SHELL_UID is missing:

private static final int SHELL_UID = Process.SHELL_UID;

If I look in standard android.jar the SHELL_UID it's there. There are many more cases like this. What could be wrong here?

Screen1: enter image description here

Screen2: enter image description here

-----> UPDATE 2 FIXED ISSUES:

Added excluded-paths also found out that I had to delete the dependencies in the Project structure:

enter image description here

In PackageManagerService.java it still cant resolve symbol:

enter image description here

-----> UPDATE 2 OPEN ISSUES:

And in this Manifest (and others) it cant resolve several symbols (related to Android): enter image description here


Solution

  • This is not a common problem I'm aware of, so I'm not entirely certain why you are seeing this error specifically. Regardless, to avoid the IDE getting confused, you could add external/roboelectric to a custom excluded-paths file so Idegen will ignore it in the generated IDE classpath.

    If you don't already have one of these files, it goes in the top-level directory of your AOSP tree, and contains directories to exclude during generation. You can see the built-in exclude file for example syntax.

    Idegen is supposed to exclude all JAR files, but it may only do that for files in out/ and prebuilts/.