Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source Documentation for Android 12 (SDK 31) is missing in Android Studio. Is there a fix/workaround?

With the newest Android 31 SDK (Android 12), the documentation for the SDK is missing.

The SDK Manager shows that the "Sources for Android X" exists for SDK 30 but is missing for 31:

"Sources for Android 30" exists but not for SDK 31

The documentation displays nothing:

Documentation returns nothing

Other used versions: Build Tools Version 31.0.0, Gradle 7.2, Android Gradle Plugin 7.1.0-alpha08

Is there any way to either get the documentation for SDK 31 or at least get the documentation for SDK 30 whilst still using 31?


Side note:

What usually works for loading a missing documentation is opening a Java/Android class, where you will see this popup at the top of the class:

Missing documentation on Android class (PopUp)

Normally the "Download"-option would download the documentation and fix the problem. In this case however, it returns an error:

Packages Unavailable

like image 810
CodingBeing Avatar asked Aug 22 '21 12:08

CodingBeing


People also ask

How do I fix Android SDK missing?

Quick fix: Go to the Tools –> SDK manager –> SDK tools. Deselect Hide obsolete packages option on the right bottom and further install Android SDK Tools(obsolete). A new folder named Tools is now generated in the SDK directory.

How do I fix SDK location not found?

Close the current project and you'll see a pop-up with a dialog which will then proceed to Configure option. Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local. properties and select Valid Target.


3 Answers

I found a solution that lets me use the documentation for the Android SDK 30 (whilst still using SDK 31) until they supply the actual documentation for the SDK 31:

Go into C:\Users\<User>\AppData\Local\Android\Sdk\sources (or a different directory where your SDKs are saved) and copy the contents of the folder named "android-30" (or the highest version you've got) into a newly created folder named "android-31". That's it.

Addition: Since it seems like it's not working for everyone: I'm using the newest Canary version of Android Studio, with everything (Gradle, libraries etc.) as up to date as possible.

like image 107
CodingBeing Avatar answered Sep 28 '22 10:09

CodingBeing


The SDK 31 sources are available now through the Android Studio SDK manager or dl.google.com/android/repository/sources-31_r01.zip

like image 36
Thomas W. Avatar answered Sep 28 '22 10:09

Thomas W.


You can attach sources from android SDK 30 as @CodingBeing mentioned, but there are extra steps to make it work.

  • Go into your SDK location (probably C:\Users\<User>\AppData\Local\Android\Sdk) into sources folder
  • Copy android-30 directory as android-31
  • And now you should open a android-31/package.xml with your favourite text editor and carefully replace all the 30s to 31s (3 places)
  • Also, do the same to android-31/source.properties(1 place)

And it should finally work, at least in stable Android Studio Arctic Fox 2020.3.1 Patch 2.

like image 31
Aleksei Potapkin Avatar answered Sep 28 '22 08:09

Aleksei Potapkin