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

Luke picture Luke · Apr 23, 2016 · Viewed 50.9k times · Source

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

Answer

Miguel Lavigne picture Miguel Lavigne · May 17, 2016

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.