找不到Android API 23平台的来源(Android Studio 2.0)

找不到Android API 23平台的来源(Android Studio 2.0)

问题描述:

Android Studio无法将我正确重定向到API源。当我执行任何功能时,它将反编译.class文件字节码,而不是从sdk / sources树访问正确的文件。

击中下载和刷新选项没有任何作用。实现侦听器特别烦人,因为它会生成函数的标头,而文档中没有变量的鬃毛(例如var1,var2等)。我已经安装了API 23(SDK平台,工具,文档,源代码)。我将编译和目标SDK设置为23。
我试图重新安装SDK工具,从canary通道更新AS,使缓存无效,但到目前为止没有任何帮助。
我切换到API 21,并且工作正常。

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.

我丢失了什么?

我的build.gradle:

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'
}

下面您可以找到a的gradle输出具有相同API 23集和相同行为的空白项目(无第三方库)。

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


对于面临相同问题的人们,解决方案在针对Linux的帖子中,并在同一主题在Windows中(感谢 Aamir Abro )。基本上,您必须针对缺少的API级别编辑 jdk.table.xml 文件。我不知道为什么,但是Android 2.0和2.1 RC并未在&lt中填充< root type = composite /> ; sourcePath> 。我更新了源代码的路径< root type = simple url = file:// D:/ android / sdk / sources / android-23 /> 和现在可以了。

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.

对于Windows用户文件位置 C: \用户{USER_NAME} 。AndroidStudio2.0\配置\选项\jdk.table.xml

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

对于Linux用户文件位置〜/ Library / Preferences / AndroidStudioBeta / options / jdk.table.xml

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

编辑:

对于某些人而言,重置SDK位置有助于来源

For some people resetting SDK location helped source.