The following steps will show you how to bind the source code to the jar library in Android Studio!!!
1. Add a jar dependency in Build.gradle:
dependencies {
Compile Filetree (dir: ' Libs ', include: [' *.jar '])//For the. Jar Library under Libs
Compile files (' libs/xxxx. Final.jar ')//for the specified file
}
2. Rebuild to a *.class file in the Jar library and look at the upper right corner (is not found attach sources option):
3. Select XX.source.jar according to the steps in 2 to bind the source code (or choose SRC Source directory)
4. In addition to the methods above, you can also use the manual import method:
(1) Open the "project directory \.idea\libraries" folder, find "Xx_library_name.xml", I am here Android-support-v4.jar library, so the corresponding is "android_support_v4.xml "
(2) Add the following fragment, URL specify Source.jar address or directory address.
If *.jar, then the following way:
<SOURCES>
<root url= "jar://$PROJECT _dir$/xxx_project/sources/xxxx. final-sources.jar!/"/>
</SOURCES>
If the directory, then the following way:
<SOURCES>
<root url= "File://X:/XXX/android-sdk-windows/extras/android/support/v4/src/java"/>
</SOURCES>
Similarly, if you add JAVADOC, add <javadoc/> Tags!
Add source source code to the jar in Android studio