Android Studio, download soruces android-27 to target latest SDK

Hugo Allexis Cardona picture Hugo Allexis Cardona · Nov 14, 2017 · Viewed 8.9k times · Source

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.

Answer

CommonsWare picture CommonsWare · Nov 14, 2017

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.