为什么我只看到官方android类的反编译源代码? [英] Why am I seeing only decompiled source for an official android class?

查看:196
本文介绍了为什么我只看到官方android类的反编译源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,我之前已经通过AS 3.5.2 SDK管理器安装了 Android SDK文档

Please note that I have previously installed Documentation for Android SDK via AS 3.5.2 SDK manager

在编辑Java源代码时,请考虑以下不一致的行为...

Consider the following inconsistent behavior whilst editing java source code ...

import android.app.Fragment;    // Deprecated! 

如果将鼠标悬停在 Fragment 上,则会获得格式精美的JavaDoc广泛帮助.此外,在文档"窗口的底部,有一个选项 Fragment 的外部文档,该文档链接到本地​​文件:

If I hover over Fragment I get extensive, beautifully-formatted JavaDoc help. Furthermore, at the bottom of the Documentation window there is an option External documentation for Fragment that links to a local file:

file:///home/daz/Android/Sdk/docs/reference/android/app/Fragment.html

现在,移动到androidX ...

import androidx.fragment.app.Fragment;
import androidx.constraintlayout.motion.widget.MotionLayout;

如果我将鼠标悬停在 Fragment 上,我会得到一个简短的帮助,该帮助将我带到框架"文档. (不太优雅但可以接受)

If I hover over Fragment I get an abbreviated help which directs me to the 'framework' documentation. (Less elegant but acceptable)

但是,如果我将鼠标悬停在 MotionLayout 上,除了对

But if I hover over MotionLayout I get nothing except a reference to

Gradle: androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar

如果我转到声明,则会得到反编译的源代码,每当我尝试编写方法代码时,都必须在Internet上搜索参数.查看反编译源时,所有尝试选择下载的尝试均以失败告终.

If I go to the declaration I get decompiled source and whenever I try to code a method I have to search the internet for the parameters. All attempts to Choose or Download sources while viewing the decompiled source have failed.

我认为这是不可接受的-存在良好的文档,我想轻松地获得它!

I consider this unacceptable - good documentation exists and I would like to get to it easily!

https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout

我很欣赏 MotionLayout 是一个相对较新的公告(2018),但这不是一个孤立的案例.

I appreciate that MotionLayout was a comparatively recent (2018) announcement but it is not an isolated case.

为什么会这样?为什么Android Studio无法找到官方的Android源代码?

Why is this happening? Why is Android Studio unable to find official Android source code?

推荐答案

确定源.jar是否与 .aar 一起提供:

Determine if the source .jar was shipped with the .aar:

示例: androidx.fragment.app.Fragment
假设外部库:等级:androidx.fragment:fragment:1.1.0@aar

Example: androidx.fragment.app.Fragment
Assumes External Library: Gradle: androidx.fragment:fragment:1.1.0@aar

EITHER右键单击外部库(从 Project 视图)->库属性...
或导航到:

EITHER Right-click the external library (from Project view) --> Library Properties ...
OR Navigate to :

.../.gradle/caches/modules-2/files-2.1/androidx.fragment/fragment/1.1.0

展开子文件夹并确认类似

Expand the subfolders and confirm something like

b9ebb04df2cb0cad4419af3c658690bc82aa5706/fragment-1.1.0-sources.jar

示例: androidx.constraintlayout.widget.ConstraintLayout
假设外部库:等级:androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar

Example: androidx.constraintlayout.widget.ConstraintLayout
Assumes External Library: Gradle: androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar

使用上述方法,您将快速确定不存在 sources.jar . (您只会看到 .aar .pom )

By using the above method, you will rapidly determine that no sources.jar exists. (You will only see the .aar and the .pom)

确定为什么不超出此问题的范围.

Establishing why not is beyond the scope of this question.

直到有人提供了更令人满意的答案之前,您可能都想尝试一下肮脏的骇客.

Until some-one provides a more satisfactory answer, you may like to try this grubby hack.

更新2019年11月21日:
如果您的问题与ConstraintLayout或MotionLayout有关,请为这个已知的问题加注星标.

Update 21Nov2019:
If your problem relates to ConstraintLayout or MotionLayout please star this known issue.

这篇关于为什么我只看到官方android类的反编译源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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