问题
Please note that I have previously installed Documentation for Android SDK via AS 3.5.2 SDK manager
Consider the following inconsistent behavior whilst editing java source code ...
import android.app.Fragment; // Deprecated!
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
Now, moving to androidX ...
import androidx.fragment.app.Fragment;
import androidx.constraintlayout.motion.widget.MotionLayout;
If I hover over Fragment I get an abbreviated help which directs me to the 'framework' documentation. (Less elegant but acceptable)
But if I hover over MotionLayout I get nothing except a reference to
Gradle: androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar
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
I appreciate that MotionLayout was a comparatively recent (2018) announcement but it is not an isolated case.
Why is this happening?
回答1:
Determine if the source .jar was shipped with the .aar:
Example: androidx.fragment.app.Fragment
Assumes External Library: Gradle: androidx.fragment:fragment:1.1.0@aar
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
Example: androidx.constraintlayout.widget.ConstraintLayout
Assumes External Library: Gradle: androidx.constraintlayout:constraintlayout:2.0.0-beta3@aar
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.
Update 21Nov2019:
If your problem relates to ConstraintLayout or MotionLayout please star this known issue.
来源:https://stackoverflow.com/questions/58925243/why-am-i-seeing-only-decompiled-source-for-an-official-android-class