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

Android Studio 没有正确地将我重定向到 API 源代码。当我命中任何函数时,它都会反编译。类文件字节码,而不是从 sdk/source 树访问正确的文件。 点击“下载”和“刷新”选项没有任何作用。实现侦听器特别烦人,因为它从文档(例如 var1、 var2等)生成的函数头没有变量的名称。我已经安装了 API 23(SDK 平台、工具、文档、源代码)。我已经将编译和目标 SDK 设置为23。 我尝试重新安装 SDK 工具,从金丝雀通道更新 AS,使缓存失效,但到目前为止没有任何帮助。 我换成了 API 21,效果很好。

我错过了什么?

我的建筑:

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

下面您可以找到一个空白项目(没有第三方库)与相同的 API 23设置和相同的行为的分级输出。

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
55930 次浏览

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'

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.

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.

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!

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.

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.