Having the source code attached to external libraries is awesome. Where do I find the source code for the v4 support package? Preferably, it would be a zip file which could be easily attached to the android-support-v4.jar
in Eclipse.
The Design Support library adds support for various material design components and patterns for app developers to build upon, such as navigation drawers, floating action buttons (FAB), snackbars, and tabs. The Gradle build script dependency identifier for this library is as follows: com. android.
Official Description: The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs. Compatible on devices running API 14 or later.
I just want to add yet another method of attaching sources for the support library. It requires ADT in version 20 or later. Supposedly this method works for all JARs for which setting source/javadoc location is disabled by the container. Here's what you need to do:
The android-support-v4.jar
library lies in the libs
directory of your project. In that same directory create a regular Java properties file named exactly like the JAR in question, but with appended .properties
extension. So, for our support library it'll be:android-support-v4.jar.properties
.
Open created properties file and set value of property named src
to the location where sources for that library can be found. Your file should have one line like:
src=c:/apps/adt-bundle-windows-64bit/sdk/extras/android/support/v4/src
Save the file.
Close and re-open your android project.
Try browsing to one of the support classes. The source attachment should work now.
Worked perfectly in my case.
One thing to note: if src
is not an absolute path, it will be resolved starting in the parent directory of the JAR file. Taking support library as an example - if src=support/src
, ADT will assume that the class sources are located in libs/support/src
.
Short description of this feature written by its author can be found here.
If anyone is interested in how exactly this .properties
file is processed, I recommend reading patch set #4, esp. changes in eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/ internal/project/LibraryClasspathContainerInitializer.java
:)
Edit
Please also see a fine comment by WindRider about adding sources properly in a project with multiple referenced libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With