18

I meets some problems so I want to find the source code of the Android support libraries . For example , I want to read the ActionBarActivity.java source code in version 19.0.1 and 20.0.0 in support.appcompat-v7 , and find out the difference between the two versions.

I found the https://github.com/android/platform_frameworks_base , but the release have named as android-x.x.x_rxx but not like 19.0.1 .

binkery
  • 295
  • 1
  • 3
  • 9
  • 2
    I'm not sure I see the problem with the Github repo. The branches correspond to Android releases, which map directly to API version numbers. For example, Marshmallow is API 23 – OneCricketeer Sep 03 '16 at 15:52
  • 2
    @cricket_007 The problem is that I use Support Library v.23.4, and the repo has refs like "android-6.0.1 r49" and "marshmallow-dr1.5-release" :-( – Orc JMR Sep 07 '16 at 05:54
  • 1
    I've tracked my 23.4 stacktraces to be from commit 73ec51559a791cf9fe5cfe624eee8d82b9777fb5 on March 30... But this commit only touches RecyclerView, and next RecyclerView commit (that does not match stack trace again) was on the same day, so I can't even tag the source myself. – Orc JMR Sep 07 '16 at 07:11
  • 2
    @OrcJMR See http://stackoverflow.com/a/39314296/746347 `/extras/android/m2repository` contains `*-sources.jar` for every support library version. – mixel Sep 09 '16 at 10:16

6 Answers6

4

You can download prebuilt source jars by version from here https://android.googlesource.com/platform/prebuilts/maven_repo/android/+/master/com/android/support/appcompat-v7

Although it seems they have removed sources for anything older than 22.1.0 there.

Alternatively you can get all changes for a specific file here https://android.googlesource.com/platform/frameworks/support/+log/master/v7/appcompat/src/android/support/v7/app/ActionBarActivity.java

Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • also I wrote this small script to automatically download all available source jars for the specified support package https://gist.github.com/ktnr74/d402b6a083f63e0bb4398231e3cfd68d – Alex P. Sep 10 '16 at 16:43
  • Awarded bounty to your answer because it's helpful. But I'm not satisfied and still looking for the right way to get diff from official repository (see also http://stackoverflow.com/q/39315958/746347). – mixel Sep 10 '16 at 22:28
2

You can browse to your sdk directory and support directory and you can find the aar files there- on mac its i located on

/Users/username/Library/Android/sdk/extras/android/m2repository/com/android/support/

Ensure you are having the the version you want to see. And Then change the version in your gradle.build to the one you need. Then sync the project, Now Change the explorer mode of android studio to the project mode.

enter image description here

Now you can browse to the external libraries to see the sources.

enter image description here

Sanjeet A
  • 5,171
  • 3
  • 23
  • 40
-1

So simple Just create a project with version 19.0.1 and crate other project with version 20.0.0 , then extend your activity from actionbaractivity or else , Hold on ctrl key and click on actionbaractivity .

Sajad Rahmanipour
  • 397
  • 1
  • 3
  • 20
-1

If you have downloaded the sources, you should be able to find them versioned at one of these three places (using OSX, but should be familiar enough to deduce the OS locations)

Android Sources

~/Library/Android/sdk/sources/

Maven Local Repo

~/.m2/repository

Gradle Cache (location could probably be a different name)

~/.gradle/caches/modules-2/files-2.1

Using either of these, it shouldn't be too hard to do a diff of the source code that you need.

Shiraaz.M
  • 3,073
  • 2
  • 24
  • 40
  • `~/Library/Android/sdk/sources` contains sources for Android SDK versions not Android Support Library versions. Mavel Local Repo and Gradle Cache does not contain sources. – mixel Sep 09 '16 at 10:11
  • @mixel The Maven Local Repo and Gradle Cache will contain sources as a jar file. – Shiraaz.M Sep 12 '16 at 19:10
-1

If you don't want to use any IDE, you can download command line tools only from https://developer.android.com/studio/index.html#downloads

This example is for OSX:

  1. After download command line tools, you can run SDK Manager using this command: "sh android", maybe you need to add "sudo" before the command.
  2. SDK Manager will show up Android SDK Manager
  3. Select Sources for Android SDK or any packages you want to download Download sources
  4. Click button Install, and accept licences.
  5. After download succeed, you can navigate to the folder where you put the SDK, and then go to sources and navigate to ActionBarActivity or any sources you wantSources of Android code
HendraWD
  • 2,984
  • 2
  • 31
  • 45
  • You does not answer the question. OP is searching for sources for two different versions of support library and wants to find difference between them. – mixel Sep 09 '16 at 10:06
  • @mixel How is it doesn't answer? We have the source code after download the support libraries we want, like support library for android Kitkat is inside android-19 folder, or for android Marshmallow is inside android-23 folder. It is pretty much reflect the version itself like the OP wants. From there we can use any text editor we want to check the different of each source code or even use "diff" command from terminal. – HendraWD Sep 09 '16 at 10:15
  • Because OP wants to see difference between support library versions and not Android versions. 19.0.1 and 20.0.0 is not Android API levels but support library versions. Actually sources for support libraries can be found at `extras/android/m2repository` in `*-sources.jar` archives. – mixel Sep 09 '16 at 10:21
-1

You can use grepcode to see Android source code

For example you want want to see ActionBarActivity.java source code in version 19.0.1 and 20.0.0 in support.appcompat-v7 .

Well API 19.0.1 will be Android version 4.4 as seen from Wiki

Now you can pick desired android version from grepcode. For example you can see Android 4.4 (Api 19) source code on grepcode here

Next you can see source code for ActionBarActivity inside support package

Similarly you can see Android source code for different build versions without IDE.

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
  • 19.0.1 is not an API version of Android. It's the version of Android Support Library. It have totally separate and independent versioning from Android. – mixel Sep 09 '16 at 16:37