zhyper
zhyper

Reputation: 183

Cannot find Android support libraries source code (v4, v7 & v13)

I am unable find the source when after I downloaded the SDK. Has it been removed from public access?

Upvotes: 18

Views: 15397

Answers (5)

Lii
Lii

Reputation: 12112

I found my sources in the following directory:

<SDK_DIR>/sources/android-26
<SDK_DIR>/sources/android-28

Setting those directories in Android Studio allowed it to attach to the sources.

Sources for some components are only available in some of the version specific sub-directories.

I'm on Windows 10, using Android Studio 3.4.

Upvotes: 0

zombielei
zombielei

Reputation: 163

Using Android Studio to read support library source is a more convenient way.Please follow these steps:

  • Add dependency to support library in build.gradle. For example, compile 'com.android.support:appcompat-v7:23.1.0' in Android Studio project's build.gradle.
  • Sync or build your project.
  • Add a reference to support library class from your code file and then ctrl+right click.This will lead you to the source code.
  • There is a "Scrool from Source" toolbar button in project view.Click it and you will be navigated to the source code tree in project view.For example, at $PROJ/build/intermediates/exploded-aar/com.android.support/design/23.1.0/jars

Upvotes: 0

Alex Lipov
Alex Lipov

Reputation: 13938

Those that are looking for sources per version, can find it locally (provided that you downloaded it previously) at:

$SDK_DIR/extras/android/m2repository/com/android/support/$libname/$version/$libname-$version-sources.jar

Jar file (as you probably know) is essentially a zip file - therefore you can simply extract its contents.

For example, support-v4 v23.1.1 located at:

$SDK_DIR/extras/android/m2repository/com/android/support/support-v4/23.1.1/support-v4-23.1.1-sources.jar

Upvotes: 3

Kasra Rahjerdi
Kasra Rahjerdi

Reputation: 2503

Some of the src folders on my copy of the samples, found at $SDK_DIR/extras/android/support/ seem to be empty. For example, v7/gridlayout/src/ is an empty folder, but most of my v4 folders have the source code supplied alongside the download from the SDK Manager, so I'm going to guess you and I are seeing the same issue.

However, you can always download the source directly from the source (no pun intended):

Doing a git clone https://android.googlesource.com/platform/frameworks/support/ to download the support library files direct from Google's repository seems to contain all of the source files.

Upvotes: 38

Junaid Akram
Junaid Akram

Reputation: 111

go to Android SDK manager then> go to extras>select Android Support Libraries >check on that and install it

Upvotes: -3

Related Questions