6

I'm trying to find the source code for Android SDK classes such as View, Canvas, and Bundle. Where can I find the source code for these classes and is it even possible?

Michael Celey
12.7k6 gold badges61 silver badges63 bronze badges
asked May 7, 2015 at 16:03
2
  • Post what code you have tried so far, explain more. Commented May 7, 2015 at 16:05
  • I want to know that the classes such as View class and or Bundle class, How are written? I want to see the codes of the classes such as Bundle class. Commented May 7, 2015 at 16:10

3 Answers 3

7

The source code for built-in classes (those that are part of the Android SDK) can be viewed by downloading the SDK source code using the SDK Manager.

From within Android Studio, navigate to Tools -> Android -> SDK Manager. Once open, you'll need to download the Sources for Android SDK as shown below.

SDK Manager

Once you have the sources downloaded, you can find the source code inside of the "sources" folder of your SDK (wherever that may be on your computer). Below I've added an image to show where you would find the View.java class inside of the SDK source files. To find other classes in the SDK, navigate to them using the package name as a hint to their location in the folder structure. (e.g. android.app.Activity -> android/app/Activity.java).

View.java location

Also, if you download the source code for a specific version, then make that version your compileSdkVersion version in your build.gradle file, you can access source code from directly within Android studio by command clicking on the class name. So if you download the sources for API 21, then set your compileSdkVersion to be API 21 as shown below, you won't have to navigate your file system to find the file.

build.gradle

answered May 7, 2015 at 16:28
Sign up to request clarification or add additional context in comments.

Comments

1

Google has a site that provides Android source code. Visit https://android.googlesource.com. I was able to find the source code for view.java on that Google site.

answered Jul 14, 2020 at 22:37

Comments

0

For example you have to view source code for veridex report line: Landroidx/transition/ViewGroupUtilsApi14;->cancelLayoutTransition(Landroid/animation/LayoutTransition;)V

Then you step: Android Studio -> Project -> External Libraries -> Gradle: androidx.transition:1.2.0@aar -> classes.jar -> androidx.transition -> ViewGroupUtilsApi14

answered Mar 17, 2021 at 7:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.