Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AOSP: How to build /platform/frameworks/base or /platform/frameworks/support separately in Android Studio

Is there a way to build AOSP's /platform/frameworks/base package source or support library source separately in Android Studio.

I wanted to read the framework (base and support) code in Android Studio and since I didn't want to be bothered about the rest of the packages in AOSP, I only imported the mirrored repo of these two packages as two separate projects in Android Studio. I want to browse through the code by using "jump to source" shortcut (cmd/ctrl+click) of the IDE. But this handy feature won't simply work properly in Android Studio. When I try to jump to the method definition which belongs to a different java source file (It says - "Cannot find declaration to go to"). This limitation of source editor is due to gradle build failure. The project just won't build and throws the following error.

Error:You need a symlink in prebuilts/sdk/99 that points to prebuilts/sdk/current.Without it, studio cannot understand current SDK. ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99

Is there a way to fix this. I know I can simply browse the source code on http://androidxref.com/ too, but it's not as convenient and powerful as your IDE.

like image 716
epiphany27 Avatar asked Feb 13 '26 15:02

epiphany27


1 Answers

This is possible (having Android Studio be able to show you the framework code and let you use the usual IDE tools), though compiling won't work. But the detail in your question seems to indicate you don't actually care about compiling, just about viewing/editing.

The first steps listed here: http://ronubo.blogspot.com/2016/01/debugging-aosp-platform-code-with.html might work for you. Basically:

  1. Build your AOSP platform ( . build/envsetup.sh && lunch - && make ...)
  2. Create the Android Studio project for importing to ( mmm development/tools/idegen && development/tools/idegen/idegen.sh )
  3. Import the project ( open android.ipr from Android Studio)
like image 153
Eddy Talvala Avatar answered Feb 16 '26 05:02

Eddy Talvala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!