How can I view the source of the Android Support Library?

Viewed 624

I'm having issues viewing any of the Java source code for all of the Android Support Library. This encompasses classes like Fragment, ViewPager, etc. I've added dependencies in my gradle build file, and can view these dependencies in the Project Structure dialog:

Gradle

Project Structure

When I try to view the source code, I only have the option of viewing the decompiled class file (example). I've run into this issue several times over the course of the past several years, but there have been a decent number of changes to Android Studio (currently using 3.3), so the ways I used in the past and many of the ways I've seen on StackOverflow seem outdated.

Approaches that I've tried:

-The Download Sources option. Nothing happens when clicking on this.

-The Choose Sources... option. Not really sure where to choose from.

-Adding an explicit call to ask idea to download sources and javadocs. Read this in a few StackOverflow posts, but it didn't change anything on my end.

What I found but haven't tried:

-Grabbing the .jar from the .aar and putting it in libs. This feels like a hacky workaround, especially when all of Google documentation suggests to add the dependency in the gradle build file.

Definitely appreciate any help, because I'd really rather not just look up the code in my browser. Thanks so much in advance!

1 Answers

You can find the source code of the Framework here. For instance the link to the Fragment is this one. If you are looking for a specific class - let's say Fragment - its easiest most of the time to just google "fragment.java android" or something similar and you will find it. If it does not help just use the first link, but keep in mind that it might be difficult to find out in which subfolder the file you are looking for is.

Related