Sources for Android API 24 Platform not found (Android Studio 2.1)
Asked Answered
C

7

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?

Cariecaries answered 6/7, 2016 at 21:30 Comment(0)
C
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.

Cariecaries answered 6/7, 2016 at 21:30 Comment(6)
Does "should take care of this" means that Android Studio will show API 23 sources when possible on API 24 projects?Dionedionis
@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).Cariecaries
It's using android.jarunder 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 24Dionedionis
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.Flittermouse
@Ernest You need to restart the IDEDionedionis
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.Macro
S
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!

Strophe answered 25/8, 2016 at 7:52 Comment(3)
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.Pacificas
@Pacificas 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.)Strophe
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 :-)Cariecaries
C
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.

Cariecaries answered 6/7, 2016 at 21:30 Comment(6)
Does "should take care of this" means that Android Studio will show API 23 sources when possible on API 24 projects?Dionedionis
@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).Cariecaries
It's using android.jarunder 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 24Dionedionis
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.Flittermouse
@Ernest You need to restart the IDEDionedionis
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.Macro
D
0

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

Dagley answered 12/7, 2016 at 2:44 Comment(1)
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.Cariecaries
M
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!

Maraca answered 12/7, 2016 at 3:2 Comment(2)
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.Maraca
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.Cariecaries
I
0

enter image description here

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

Intrusion answered 23/7, 2016 at 18:22 Comment(1)
Not sure why people downvoted this. I see the same thingIquitos
K
0

File - Invalidate Cashes and Restart this works for me.

Kharif answered 20/12, 2016 at 19:41 Comment(0)
C
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.

Corinecorinna answered 6/4, 2021 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.