“转到实施"Android API 类打开 .class 文件,而不是 .java [英] "Go to implementation" of an Android API class opens .class file, not .java

查看:41
本文介绍了“转到实施"Android API 类打开 .class 文件,而不是 .java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Android Studio 0.4.0 中开发应用程序(但此问题也发生在早期版本中),当我尝试使用 IDE 的快捷方式转到实现"访问特定于 Android 的类的实现时,它打开该类的 .class 文件,而不是 .java.

I'm developing an app in Android Studio 0.4.0 (but this issue happened also on earlier versions), and when I try to access the implementation of an Android-specific class using the IDE's shortcut "Go to implementation", it opens the .class file of that class, and not the .java.

在另一台计算机和不同的项目中,我确定快捷方式会打开 java 文件,这是需要的,因为我可以看到实际的实现代码、注释和 javadoc.

In another computer and different project, I'm sure that shortcut opens the java file, which is desired because I can see the actual implementation code, comments, and javadoc.

例如,我有这个类:

package com.example;
...
import android.app.Fragment;

public class MyFragment extends Fragment {
    ...
}

当我在 Fragment 上插入插入符号并执行转到实现"时,它会打开 $ANDROID_SDK/platforms/android-19/android.jar!/android/app/Fragment.类.预期的行为应该是打开 $ANDROID_SDK/sources/android-19/android/app/Fragment.java(或其他地方有正确的 Fragment.java 文件).

When I have the caret on Fragment and do "Go to implementation", it opens $ANDROID_SDK/platforms/android-19/android.jar!/android/app/Fragment.class. The expected behaviour should be to open $ANDROID_SDK/sources/android-19/android/app/Fragment.java (or where ever else lies the correct Fragment.java file).

在 SDK 管理器中,我确定我下载了 Android SDK、API 19 和 API 17 的源代码.我的清单文件指出:

In the SDK manager, I'm sure I downloaded the sources for Android SDK, API 19 and API 17. My Manifest file states:

<uses-sdk
    android:minSdkVersion="17"
    android:targetSdkVersion="17"
    />

将目标 SDK 更改为 19 无效.

Changing the target SDK to 19 has no effect.

有什么想法吗?

推荐答案

基于 Gradle 的 Android Studio 项目尚不支持将源 jar 或目录附加到包含的库.您可以用来跟踪进度的最接近的错误是:

Attaching source jars or directories to included libraries isn't supported yet in Gradle-based Android Studio projects. The closest bug you can use to track progress is:

https://code.google.com/p/android/问题/详细信息?id=59220

这篇关于“转到实施"Android API 类打开 .class 文件,而不是 .java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆