I am new to Eclipse and I could not solve this problem.
How could I import this library to Eclipse using the default builder (not using Gradle)?
Without using Gradle/Maven and using Eclipse you need to manually add the library.
The library is in the jcenter repository, which means there is a jar file available. This jar file can be found here (I'm pretty sure you need the -sources.jar)
Download this library and save it in a logical place. Go to Eclipse, highlight the project and press Alt+Enter. Go to the Java Build Path page and click Add External JARs under the Libraries tab. Select the JAR file and it should be fine.
Keep in mind that the Eclipse ADT plugin is not the way Google wants you to do it. If you have no reason to use Eclipse other than that it's what you have set up now, you should probably move to Android Studio.
Create a new project and add github version project files to newly created project else download the entire project from github and add this project to your current project.
right click(current project) -> Build path -> Configure build path -> Java build path -> Projects (tab) -> click add
Just add this project there and build your project.
I found this library to make a "undobar" (https://github.com/jenzz/Android-UndoBar), but I do not know how to install it. On some websites I read that I must right click on my project, then go to Properties-> Java Build Path-> Libraries-> Add External JARs and select the Zip file that I downloaded, but it's still not working.
What am I doing wrong?
Clone the GitHub project locally to your machine.
Import the lib as a project into Eclipse
RightKlick on your project in the Package Explorer selecting Properties / Android
Under Library klick on add and select the lib's project
Some aditational OK's should do the trick.
I read all posts that answer this question but they all are old and didn't work for me.
Is there any way to just attach source code to the Support Library (v4, v7, app_compat..) in Eclipse and avoid seeing the message "This element neither has attached source nor attached Javadoc and hence no Javadoc could be found. note"?
Somebody told me there is no way to do it since it is closed source, is that true? Since there is nothing under the library's source folder.
Thanks.
Here is what solved the problem for me. My project depends on appcompat_v7 library, which (I think) provides the android-support-v4.jar file to the project. I created android-support-v4.jar.properties file exactly as guided in How can I enable javadoc for the Android support library?. Added that file to lib folder in appcompat_v7 rather than project's lib folder.
Try this one:
1) Download jar file containing the JavaDocs.
2) Open the Build Path page of the project (right click, properties, Java build path).
3) Open the Libraries tab.
4) Expand the node of the library in question (JavaFX).
5) Select JavaDoc location and click edit.
6) Enter the location to the file which contains the Javadoc (the one you just downloaded).
Hope this helps.
Source: How to attach source or JavaDoc in eclipse for any jar file e.g. JavaFX?
UPDATE:
If you don't have javadocs itself, you can generate them by yourself:
cd <path_to_android_sdk>/extras/android/compatibility/v4/
mkdir docs
javadoc -d docs -sourcepath src\java -subpackages android.support.v4
Source: How to install javadoc for Android Compatibility Package?
I am trying to implement the actionbarcompat support library project in my android application and I have followed the guidelines here from the android website on how to implement these but the resources of the support library still are not available to my project.
Note: I am able to use methods defined from the compiled classes of the library project, I just don't know how to reference from the styles.
I am using eclipse IDE.
Anybody with an idea how or what I am doing wrong please assist me.
I happen to have found my own mistake! Most certainly I know a few others might go the same path.
These are the steps in adding a support library with resources.
Select File > Import.
Select Existing Android Code Into Workspace and click Next.
Browse to the SDK installation directory and then to the Support Library folder /extras/android/support/v7/appcompat/.
Click Finish to import the project. You should now see a new project titled android-support-v7-appcompat.
In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > add both the
android-support-v4.jar and android-support-v7-appcompat.jar files to
the build path.
6.Right-click the project and select Build Path > Configure Build Path.
7.In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on
this library project. The appcompat project requires you to export
both the android-support-v4.jar and android-support-v7-appcompat.jar
files. Uncheck Android Dependencies.
8.Click OK to complete the changes.
Now You add the library project to your application:
In the Project Explorer, right-click your project and select Properties.
In the Library pane, click Add.
here is where I went wrong. Check if you've done it the right way too (As shown)
Select the library project and click OK. The appcompat project should be listed as android-support-v7-appcompat.
In the properties window, click OK.
Look at the "Adding libraries with resources" section of this document
http://developer.android.com/tools/support-library/setup.html
Basically, you import the resources in a library project called "android-support-v7-appcompat" that you reference in your app project.
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.
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.
Here the solution to attache the source of the support library in Eclipse Juno
I suppose that your project already has android-support-v4.jar in your "Build Path", under "Android Dependencies", but you cannot attach the sources directory to it. (the "Source attachment" said "Non modifiable"). Solution:
Goto "Configure Build Path"
Add External JARs > YourProject/libs/android-support-v4.jar
(I know your project had already referenced to it but don't worry, just add it again).
Expand jar and attach Source to the External Jar: android-sdk/extras/android/support/v4/src
Switch to the "Order and Export" tab, pull up the external jar above the "Android Dependencies"
Enjoy navigating the support library with source!
if you have an "Android Test Project" attached to YourProject, so YourProjectTest might not compiled anymore. In this case, you have to return to "Order and Export" and pull down the external jar below the "Android Dependencies" to get things back to normal.
After downloading the support package from the Android SDK Manager, you can find the source code of support package in folder <android-sdks>/extras/android/support/v4/src.
Referencing the accepted answer, it is also possible to attach the source straight from the directory without building a .jar file. From the Java build path / libraries tab, expand android-support-v4.jar, highlight "Source attachment", click "Edit...", "External Folder..." then point to (android-sdk)\extras\android\support\v4.
This was tested using eclipse indigo.
From the comments:
The problem of being unable to add source to the support library seems to occur if your support library is located in the "Android Dependencies" folder of your project. The workaround is from the same "Java build path / libraries" tab click "Add External JARs..." and find the .jar file in your (android-sdk)\extras\android\support\v4 path. It will then appear in your project setup under a new "Referenced Libraries" folder.
For those who like the standard to have the jar file of the source code, which makes it more convenient for source control and sharing the project.
For example:
../android-support-v4.jar
../android-support-v4-src.jar
It is simple to create the source jar file and attach it:
cd to path_to_android_sdk/extras/android/compatibility/v4/
Use your favorite zip program such as 7-zip to create a zip file and name it android-support-v4-src.jar. The first folder in the jar should be /scr.
Copy the file to your project, in this example it is in the same folder as the code jar.
In Eclipse attach the source jar in project properties.
I just remove the auto generated one , then manual add it as a Referencde Libraries.
First open a class, the IDE will ask you to Change Attached Source.
The process of attaching the src and doc from build path works for some and it doesn't for some (like me). some key things to keep in mind
Make sure you are in Package Explorer, not Project Navigator.
If you have put your android-support-v4.jar in libs folder under your project. great.
Right click the jar, Build path.. Add to Path. (if Add to Path does not show up then its already added. you will see configure path..)
As the result of step 3, a new folder called Referenced Libraries will appear in package explorer tree. Open that tree, find the android-support-v4.jar there. Right click on this jar in the Referenced Libraries, properties. Then set the Java Source Attachment and Javadoc Location there.
You are done.
The path for my Java Source Attachment.(its external location)
C:/Users/thupten/adt-bundle-windows-x86_64-20130514/sdk/extras/android/support/v4/src
I used the android website doc for java doc location
http://developer.android.com/reference/android/support/v4/app/package-summary.html
I found this for me:
For main lib: android.jar:
src: sdk/sources/android-19
doc: sdk/docs/reference/
For support lib: android-support-v4.jar: (before this we should add android-support-v4.jar like external jar (Project Properties -> Java Build Path -> Libraries, then in Tab ‘Order and Export’ pull up this library before Android Private Libraries)):
src: sdk/extras/android/support/v4/src/java
doc: http://developer.android.com/reference/android/support/v4/app/package-summary.html (not sure)
After you have updated the SDK and downloaded Documentations in it:
Import support library project to package explorer.
Create a folder in the library and name it something like ext-jars.
Move android-support-v4.jar to ext-jars folder.
Right click on the project and click on Properties.
Click on Java Build Path in the left menu then select Libraries tab.
Click on Add JARs... then expand the project and select the jar file you already moved to folder ext-jars.
Expand the added jar and select Source attachment then click on Edit.
Select External location then click on External Folder...
Choose the source folder for the Support v4 which is located in
[sdk-path]/extras/android/support/v4/src
Select Javadoc location click on Edit then select Javadoc URL then click on Browse... and choose the javadoc location for support v4 which is located in [sdk-path]/docs/reference/
- Select Order and Export tab and check the android-support-v4.jar you just added.
I suggest you also clean the project and reopen the Eclipse.