Add source source code to the jar in Android studio

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.