26

In Android Studio 2.1 I was using API 24 just fine, then suddenly started seeing "Sources for Android API 24 Platform not found" warning in my AndroidManifest.xml.

Rerunning the Android SDK Manager setup in Android Studio, removing other non-supported APIs, etc didn't work for me. How do I fix this?

Community
  • 1
  • 1
Mycah
  • 4,602
  • 5
  • 24
  • 32

7 Answers7

71

Try this method , I copied it from here.

Android Studio 2.1 reporting in: solved the issue by resetting SDK.

Preferences -> Appearance & Behavior -> System Settings -> Android SDK.

Click on Edit to the right of Android SDK location. Next, next, next to complete the wizard and voila!

Community
  • 1
  • 1
Veer
  • 1,373
  • 1
  • 12
  • 27
  • This method seems to trigger an indexing step that didn't happen the first time. For reference I downloaded the source via the Standalone SDK Manager. I don't know how to trigger the indexing method without following the above method. – DrZaphod Sep 06 '16 at 09:18
  • @DrZaphod You should make sure the source code is downloaded via the SDK Manager,.If it still won't work, try to use the method above. (Sorry about my poor English, I may not understand what you mean.) – Veer Sep 06 '16 at 14:11
  • 1
    Glad this is working for some people, but my question was about how to fix the problem when this solution DIDN'T work. This is the same solution (although a different post) that I linked in the question. Anyway, that's why I haven't marked this as the answer :-) – Mycah Sep 17 '16 at 15:30
5

After searching I found answers that were close enough to get me to my own answer for API 24. For me it was simply a matter of removing API 24, closing Android Studio, and (after reopening) letting Android Studio detect API 24 was missing and download it for me. I assume this would also work for other API versions.

UPDATE: As others have pointed out, API 24 did not have "Sources" listed in SDK Manager at the time this question was asked/answered. However, everything was working fine before and continues to work after following this answer. So that seems to be a bit of a technicality worth mentioning.

I have the app targeting and compiling for API 24 and on Google Play in Alpha testing.

Android N APIs are now final (as of 15 June 2016).

enter image description here

Steps (Mac):

  1. Open SDK Manager: Tools > Android > SDK Manager
  2. Remove API 24: Deselect Checkbox > Click OK, OK again to confirm removal
  3. Quit Android Studio (⌘Q)
  4. Reopen your project in Android Studio
  5. Install missing platform(s) and sync project
    • Click this clickable link in the Messages Gradle Sync panel enter image description here

Once the Gradle Sync finishes that should take care of it.

Mycah
  • 4,602
  • 5
  • 24
  • 32
  • Does "should take care of this" means that Android Studio will show API 23 sources when possible on API 24 projects? – Louis CAD Jul 13 '16 at 07:49
  • @Louis For me, it seemed that the issue was some kind of corruption etc and by following this solution Android Studio fixed it. The "Sources" still don't show up in the list under API 24 after this, but it does get things working. I'm not sure exactly how Android Studio is handling this, but it does work without "Sources" showing up in the list (maybe it's using API 23 Sources somehow). – Mycah Jul 13 '16 at 16:24
  • It's using `android.jar`under the hood. I personally copied API 23 as API 24 sources (and edited some copied xml files to be 24) because I needed to look at sources sometimes while compiling against API 24 – Louis CAD Jul 14 '16 at 14:38
  • 3
    Tried this solution, not working for me. Still showing decompiled code and 'sources not found'. @LouisCad I've tried to do the same, but no luck, AS does not recognises folder. – Ernest Poletaev Jul 20 '16 at 04:29
  • @Ernest You need to restart the IDE – Louis CAD Jul 20 '16 at 06:05
  • 4
    Not working for me either, How to use 23 api docs while using 24 api should be the question, regardless 24 api has docs or not. – XcodeNOOB Aug 02 '16 at 12:48
0

There isn't source for android 24, only version 23 of the following Sources for Android SDK 23

Yogesh Umesh Vaity
  • 41,009
  • 21
  • 145
  • 105
NotesDea
  • 19
  • 2
  • Yes, a bit of a technicality though (I think) since it was working fine before that and continues to work fine after what I posted in the solution. I updated the original question to clarify a bit. Thanks. – Mycah Jul 12 '16 at 03:44
0

Re-installing may fix some problems, but this evening (7/11/16 2300 EST) the source for 24 isn't available yet. It'll show up when google says its soup:

enter image description here

Marshmallow (23) is the last version with sources.

[update 8/26]

SDK 24 has sources now. It's soup!

evaitl
  • 1,365
  • 8
  • 16
  • The sources are the java files instead of just the jars. On my system, I can see the sources for android-23 in ~/Android/Sdk/sources/android-23. It shouldn't be an impact for building, but source is nice sometimes if the documentation isn't clear. Title for this question says that sources for 24 not found. – evaitl Jul 12 '16 at 03:27
  • Of course the title ...that was the warning I started to see although it was working fine for me up until that (sudden) point. Anyway, thanks for the feedback, I've updated the question to clarify a bit. – Mycah Jul 12 '16 at 03:40
0

enter image description here

No source for api 24.We should wait google publish sources for android sdk.

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
0

File - Invalidate Cashes and Restart this works for me.

Foenix
  • 376
  • 4
  • 18
0

I get sources for most classes from android.jar, but not android.Manifest It has some useful comments e.g. about permissions that would be convenient to have available directly in Android Studio. android\sdk\platforms\android-29\android-stubs-src.jar does contain a useful android/Manifest.java source file, however it's missing from android\sdk\sources\android-29\android. There is no "attach sources" visible anywhere as far as I can see, just get the decompiled version.

After unzipping just android/Manifest.java and restarting Android Studio, it's there! Bit of a hack but better than no sources.

Stefan L
  • 1,529
  • 13
  • 20