3

To start a new project, I want to target the latest SDK (taking advantage of the fresh start). But, I also want to have access to the Android source code to be able to read the code of android classes (like AsyncTask, just as an example). I'm targeting SDK 27 on gradle and also using compileSdkVersion 27. I've tried by different ways (as indicated here, here and here) but I can't seem to download those sources.

When I try to browse an Android class like AsyncTask for example, I get the message:

Decompiled .class file, bytecode version: 52.0 (Java 8)
Sources for 'Android API 27 Platform' not found.

Even after clicking the Download and then the Refresh (if already downloaded) links (which is the most intuitive thing to do) I still can't see the source code of any Android class.

This is an issue only for API 27. I'm able to download sources for all other API versions.

Is this because of API 27 being the latest one?

I want to avoid targeting 26. Is it possible to download those sources? Has anyone been able to do it so far?

If someone knows how to do this so far, that would be very helpful. Thanks.

I'm using Android Studio 3.0 and the download option for API 27 source is not available:

Sources for API 27 not availableNo option to download sources

UPDATE

As indicated by the accepted answer, the problem was the API Level 27 being a dev preview back then, the problem got resolved with time (once the official release happened). This update may be useful for people facing similar problems when targeting the latest available API version.

Hugo Allexis Cardona
  • 1,382
  • 19
  • 25

1 Answers1

5

Is this because of API 27 being the latest one?

No, it is because API Level 27 is Android 8.1, which is in a developer preview at the moment.

I want to avoid targeting 26

I am not certain why, considering that 26 is the API level corresponding with the latest production release of Android (8.0).

Is it possible to download those sources?

Usually, the sources are not available via the IDE until the OS release ships in final form.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • is there a way to somehow use sources of previous sdk? i guess our studio already has copies of multiple SDKs at a time, so can we manually access old documentation/source code? like am currently using sdk 29 for my app, i know google hasn't release sdk 29 sources/docs but am sure sdk 28 has all the sources/docs. can i somehow access sdk 28 docs? – ansh sachdeva Aug 19 '19 at 19:51
  • @anshsachdeva: "i know google hasn't release sdk 29 sources/docs" -- they have, at least for some of the betas. [Here is a mirror of the Q Beta 6 source](https://github.com/aosp-mirror/platform_frameworks_base/tree/android-q-preview-6). The source will not be available in the SDK Manager for installation into Android Studio until Q ships (which should be soon). "can i somehow access sdk 28 docs?" -- switch to an appropriate tag in GitHub, such as [this one for Android 9.0](https://github.com/aosp-mirror/platform_frameworks_base/tree/android-vts-9.0_r10). – CommonsWare Aug 19 '19 at 19:56
  • No I meant from inside android studio. its very beneficial to view source code and its docs via ctrl+click. – ansh sachdeva Aug 19 '19 at 20:13
  • @anshsachdeva: I have not accessed docs within Android Studio, so I am not certain what the process is for that -- sorry! – CommonsWare Aug 19 '19 at 20:28