Sources for Android API 23 Platform not found (Android Studio 2.0)
Asked Answered
V

6

103

Android Studio doesn't redirect me to API sources correctly. When I hit any function it decompiles .class file bytecode instead of accessing the right file from sdk/sources tree. Hitting "download" and "refreshing" options does nothing. It's particularly annoying for implementing listeners since it generates functions' headers without variables' manes from documentation (i.e. var1, var2 etc.). I have installed API 23 (SDK platform, tools, docs, sources). I have set compile and target SDK to 23. I tried to reinstall SDK tools, update AS from canary channel, invalidate cache but nothing helped so far. I switched to API 21 and it works fine.

What am I missing?

My build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

    defaultConfig {
        applicationId "com.myapp.app"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile project(':volley')
    compile 'com.jakewharton:butterknife:7.0.1'
}

Below you can find gradle output for a blank project (without 3rd party libs) with the same API 23 set and the same behaviour.

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2330Library
:app:prepareComAndroidSupportAppcompatV72330Library
:app:prepareComAndroidSupportDesign2330Library
:app:prepareComAndroidSupportRecyclerviewV72330Library
:app:prepareComAndroidSupportSupportV42330Library
:app:prepareComAndroidSupportSupportVectorDrawable2330Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:mockableAndroidJar
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies

BUILD SUCCESSFUL
Vaporescence answered 23/4, 2016 at 18:25 Comment(7)
please show your gradle fileEarring
I attached my build.gradle. Thanks for responseVaporescence
are you using it on Linux?Overdraw
I am facing the same problemOverdraw
this solved it for me https://mcmap.net/q/187491/-android-studio-how-to-attach-android-sdk-sourcesOverdraw
You led me to the solution. I'm running Windows so I've searched for the same file in system. There is one per Android Studio version. Actually someone posted a solution here 2 hours ago. Thanks for your help!Vaporescence
Those solutions are nice and may have worked for all. But I have found another solution, just adding it for people who can not solve this error by above methods, I just removed some apps from the emulator to free up space in it, that is all. The error resolved.Staats
V
47

For people facing the same problem, the solution is in this post for Linux and in the same topic here for Windows (thanks to Aamir Abro). Basically, you have to edit jdk.table.xml file for API level you are missing. I don't know why, but Android 2.0 and 2.1 RC don't have filled <root type="composite" /> in <sourcePath>. I updated sources' path <root type="simple" url="file://D:/android/sdk/sources/android-23" /> and now it works.

For Windows user file location: C:\Users{USER_NAME}.AndroidStudio2.0\config\options\jdk.table.xml

For Linux user file location: ~/Library/Preferences/AndroidStudioBeta/options/jdk.table.xml

Edit:

For some people resetting SDK location helped source.

Vaporescence answered 24/4, 2016 at 15:51 Comment(6)
I tried, but this not work in Android Studio 2.1, Ubuntu 16.04Shippee
Someone here wrote that reseting SDK location helped. You can also try to reinstall API sources in SDK manager and make sure jdk.table.xml has an entry to the right path for API level you are using.Vaporescence
Resetting SDK location really helped, even I didn't modify the jdk.table.xml.Shippee
for Mac User is the same : ~/Library/Preferences/AndroidStudioBeta/options/jdk.table.xmlAlvinaalvine
There is an issue about it: code.google.com/p/android/issues/detail?id=207555Gloss
For Pete's sake, I'm using Studio 3.2 Canary 11 and just had the same issue. Except now the file is $HOME/.AndroidStudioPreview3.2/config/options/jdk.table.xml, and the missing XML is <root type="composite"> <root url="file://$USER_HOME$/Android/Sdk/sources/android-23" type="simple" /> </root>Pegpega
C
215

Apparently this issue has been fixed in Android Studio 2.1. Rerun the Android SDK Manager setup in Android Studio and this should solve your issue.

In Android Studio:

Windows: File -> Settings (ctrl+alt+s) -> Appearance & Behavior -> System Settings -> Android SDK.

Mac: Android Studio -> Preferences (cmd + ,) -> Appearance & Behavior -> System Settings -> Android SDK.

Click on Edit on the right of the Android SDK location. Click Next all the way through the wizard and this should fix the problem.

This was answered here for a different question.

Creamcolored answered 17/5, 2016 at 18:36 Comment(7)
Restart to make it live.Queenstown
Brilliant! You are a champion. Reimporting fixed the issue for me.Effect
Would you marry me?Thorp
Anyone get this to work with Android Studio 2.3.3 and API 26? The issue is exactly the same in this scenario, but following these instructions and restarting did not help.Timid
Still relevant for AS 3.1.3. Thanks!Passant
Not working. Result of wizard is "Nothing to do! Android SDK is up to date." And no changes after restart AS.Disputable
This worked for me. Easiest solution. Worked on Android Studio 3.5.3Oceanic
V
47

For people facing the same problem, the solution is in this post for Linux and in the same topic here for Windows (thanks to Aamir Abro). Basically, you have to edit jdk.table.xml file for API level you are missing. I don't know why, but Android 2.0 and 2.1 RC don't have filled <root type="composite" /> in <sourcePath>. I updated sources' path <root type="simple" url="file://D:/android/sdk/sources/android-23" /> and now it works.

For Windows user file location: C:\Users{USER_NAME}.AndroidStudio2.0\config\options\jdk.table.xml

For Linux user file location: ~/Library/Preferences/AndroidStudioBeta/options/jdk.table.xml

Edit:

For some people resetting SDK location helped source.

Vaporescence answered 24/4, 2016 at 15:51 Comment(6)
I tried, but this not work in Android Studio 2.1, Ubuntu 16.04Shippee
Someone here wrote that reseting SDK location helped. You can also try to reinstall API sources in SDK manager and make sure jdk.table.xml has an entry to the right path for API level you are using.Vaporescence
Resetting SDK location really helped, even I didn't modify the jdk.table.xml.Shippee
for Mac User is the same : ~/Library/Preferences/AndroidStudioBeta/options/jdk.table.xmlAlvinaalvine
There is an issue about it: code.google.com/p/android/issues/detail?id=207555Gloss
For Pete's sake, I'm using Studio 3.2 Canary 11 and just had the same issue. Except now the file is $HOME/.AndroidStudioPreview3.2/config/options/jdk.table.xml, and the missing XML is <root type="composite"> <root url="file://$USER_HOME$/Android/Sdk/sources/android-23" type="simple" /> </root>Pegpega
P
8

As qbeck mentioned in his comment, resetting the path to the SDK fixed the issue for some of us.

Solution:

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!

Paw answered 2/6, 2016 at 21:47 Comment(2)
This fixed the issue in Android studio 2.3 w/ SDK 25Seldun
on Linux it's: File -> Settings -> Appearance&Behavior -> System Settings -> Android SDKDonaldson
C
3

Encountered the same problem for API level 28 on Android Studio 3.2.1 on Windows 10. Refresh did not work.

Worked after restarting Android Studio.

Cygnus answered 19/12, 2018 at 15:42 Comment(0)
E
1

to update your Android Studio to Api 23 go to :

Tools > Android > SDK Manager,

you can go then go to SDK Tools tab or click on Launch Sdandalone SDK Manager. check Android SDK Build-tools 23.0.2 to install

Update:

please, remove from your dependencies:

compile project(':volley')

and replace it with :

compile 'com.android.volley:volley:1.0.0'
Earring answered 23/4, 2016 at 19:38 Comment(5)
I have already installed API 23 (SDK platform, tools, docs, sources). In fact I tried to reinstall all of it, but didn't help.Vaporescence
ok, i think the problem is related to volley library.. please check my updated AnswerEarring
Still nothing. I've even setup a new project without any externals and it's still the same. It looks like more Android Studio related issue.Vaporescence
mmm, please clean up your project => rebuild and check gradle console in the bottom right of android studio.. update your question with the log you seeEarring
I attached an output from gradle for another (blank) project, where the same things happen. I appreciate your help.Vaporescence
C
0

There would be 2 errors sometimes, the first would say: 'platform android 28 not found', click next, 'accept some license agreement...'. Once you accept the agreement, both the errors will disappear.

Construction answered 15/4, 2020 at 10:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.