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?
Related
I added to my project support library android-support-v7-appcompat, but I can't add source and javadoc for it.
I downloaded https://android.googlesource.com/platform/frameworks/support/+/master package with source and in Eclipse I set Source attachment to v7/appcompat/, but it doesn't work.
Can someone help me?
E: my solution is, I have two projects in Eclipse "android-support-v7-appcompat" (original lib from android-sdk\extras\android\support\v7\appcompat) and "android-support-v7-appcompat-src" (src from android.googlesource.com) and when I compile release version, so I used original lib and for debug I used src from googlesource.com.
PS: sorry for my english
I was able to attach the source based on advice from How do I attach the Android Support Library source in Eclipse?.
Here's what I did:
First, clone the source repository and get whatever version corresponds to the released library (which I guessed):
git clone https://android.googlesource.com/platform/frameworks/support
cd support
git checkout android-4.3.1_r1
Next, in Eclipse:
Right-click project and choose Properties.
Select Java Build Path
Select the Libraries tab
Add External JARs > YourProject/libs/android-support-v7-appcompat.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: WhereverYouHaveTheSource/support/appcompat
Switch to the "Order and Export" tab, move the external jar above the "Android Dependencies"
Or the same using #andr answer to How do I attach the Android Support Library source in Eclipse?
git clone https://github.com/android/platform_frameworks_support android_sources_folder
add android-support-v7-appcompat.jar.properties file into libs (next to android-support-v7-appcompat.jar) with content
src=D:\\android_sources_folder\\platform_frameworks_support\\v7\\appcompat\\src
close and reopen project
Sources for appcompat-v7 are available within "API21/Sources for Android SDK" package which can be downloaded with SDK Manager, the path is \sdk\sources\android-21\android\support\v7\
Android Studio will allow you to browse lib source code when you point this dir as appcompat-v7 source dir root.
I'm testing the sample app for Mobile Express Checkout Library with Android.
I'm getting java.lang.NoClassDefFoundError: com.paypal.android.pizza.ResultDelegate
The error is on this Pizza.java line: PayPal.fetchDeviceReferenceTokenWithAppID(this, appID, server, new ResultDelegate());
I'm confused, i didnt find any info about that error on google, and also on the faq on paypal and x.com, so i don't know how to solve it.
I simply opened the sample code project and executed it.
This is the link to the project and the library: https://www.x.com/sites/default/files/PayPal_MECL_1.0_Android-Developer-Package_0.zip
There are only three reasons you will ever get this error:
The class genuinely doesn't exist. If you are using code from an official example and getting this, make sure you have the latest build of the library
You have not added the jar to your build path. To fix this, right click on the jar in Eclipse, and do Build Path ► Add to Build Path.
Your jar is not in the /libs folder. This happens when you have added the jar to the build path, but newer versions of ADT need it to be in /libs. Put it there and it will automatically be added to the build path. If it isn't, try doing a Clean build via ant clean or Project ► Clean in eclipse.
Mostly, such errors occur because newer versions of the ADT require all external jars to be in the libs folder.
By looking at the project you linked to, I can see the paypal jar in the project root. Instead, try moving it into a /libs folder. This should solve your problem.
I think you have not exported library jar from the configure build path section of eclipse.
create libs directory in project's directory and add move PayPal_MECL.jar to /libs. goto project properties and remove existing PayPal_MECL entry from libraries
I have come across a strange error. I have an Android project that uses external libraries, in particular:
android-support-v4.jar (for Fragment support in Android 1.6)
GoogleAdMobAdsSdk-4.3.1.jar (for ads)
The project ran fine until I updated some aspects of the plugin (can't recall the specifics as I did not pay too much attention to it) and after that, whenever I try to use any class from the above .jar files (or any of its subclasses, even ones defined by me), I would get a java.lang.NoClassDefFoundError. I could not find the answer after much searching, so I am really stumped.
I believe this problem is related to how my IDE is set up and it has little to do with actual code, so I will not post any unless if it's absolutely necessary.
You need to read this - Dealing with dependencies in Android projects.
This link is also useful - ClassDefNotFoundError with ADT 17
Basically, create a folder called libs and place all of your jar files inside. The recent update will automatically take care of the rest for you. You don't need to edit your path anymore.
Android does not support Java1.7 up to now. Jars built with compliance level 1.7 cannot be used in Android Applications. Rebuild your Java project with compliance level 5.0 or 6.0 before exporting the jar file.
I found this post via google and answers above didn't solve my problem. Hope what I say will be helpful to others.
If you see NoClassDefFoundError after upgrading to ADT 22, try this in Eclipse:
Go to Project Properties → Java Build Path → Order and Export tab.
Check the Android Private Libraries option.
Also a warning to others who have updated to r17 with many dependencies. I had a another referenced project on my build path and it still did not work after following ALL the directions on this r17 issue on the internet.
Found out after an hour that my referenced project used an older version of an external Jar than my main project did. When trying to compile the main project, Eclipse would give up due to this jar version difference and I never noticed the warning message in Console.
Solution was to copy the newer version external jar file to the referenced project's libs directory.
Wow - such a productivity killer.....
I ran into this error today too, because of updating to the Android SDK, r17. What the links that #aneal pointed out do not discuss is how to handle external runtime libraries (such as those imported under their own heading - not an imported user library).
The easiest way to solve this problem is to change the build order in the build path. Simply right click on your project and select Properties. From here, select Java Build Path. At the top of the display, choose the tab order and export and move GoogleAdMobAdsSdk-4.3.1.jar above Android X (replacing x with the version you are using). Next, clean your project and run it. You should be good to go!
The way I solved it was by : Right clicking on the project and selecting build path. Select configure build path in the selections that appear. After that see if your libraries are there in the libraries folder and then select the order and export tab and over there select all your jar files. Then select ok and run your project.
If you're using Eclipse with Maven IDE (m2e) go to "Java Build Path" then "Order and Export" and finally check the item "Maven Dependencies" and pull it down to the BOTTOM of the list. You should do the same with project references in the same workspace.
Every time I setup the project in a new computer that happens.
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.
How to generate custom javadoc for android 1.4 compatibility package?
The reference docs are available online (example), but is there some place where I can get a zip with javadoc available offline?
I suppose using the javadoc would be pretty simple, just a matter of setting the javadoc location for the compatibility jar.
You can generate your javadoc offline on your own from the source code. Just navigate to your android sdk directory then do the following
cd <path_to_android_sdk>/extras/android/compatibility/v4/
mkdir docs
For Windows:
javadoc -d docs -sourcepath src\java -subpackages android.support.v4
For Linux/Mac:
javadoc -d docs -sourcepath src/java -subpackages android.support.v4
This will generate your javadocs for you locally in the docs directory that you just created.
Then in your eclipse android project, go to your project properties where you added the your android-support-v4.jar, edit it's properties and add the the path to the javadocs you just created.
That should work!
ADT 17+ issues:
As some of you have pointed out. There have been issues getting Eclipse to see the attached javadoc for ADT 17+. This is a known issue and a bug has been filed. This is not related to the way you generate the javadoc (as I described above), rather this is an issue with ADT 17+ integrating with Eclipse. Someone has described a workaround and it can be followed here:
http://code.google.com/p/android/issues/detail?id=28801
Problem: If the android-support-v4.jar is in the /libs folder (as the ADT 17+ require) the javadoc is unavailable.
Edit: I have workarounded the problem by linking the offline version of the android javadoc to the android-support-v4.jar. As far as I know it is still not possible to link the online version (http://developer.android.com/reference). Steps:
Download the Documentation for Android SDK from the SDK Manager. You can find it under the latest Android version (4.1)
Link the javadoc folder to your project's folder, in Windows open a console and type: MKLINK /J {PROJECT_PATH}\android_docs {SDK_PATH}\docs\reference
Create the file libs/android-support-v4.jar.properties with this content:
src=android-support-v4.jar
doc=../android_docs
Close the project and reopen it. Clean if necessary.
The javadoc is linked. Check it by going to any Support library class, like android.support.v4.app.FragmentActivity
Thanks to this answer https://stackoverflow.com/a/11579339/933261
The answer by #wnafee is spot on, but if you are using Linux don't forget to use the forward slash character at this location like src/java.
IF YOU'RE ON WINDOWS and get stuck for ages like me, make sure you escape your backsmashes in the properties file, or things will silently fail. (who makes silent failing loaders anyway...)
This this is my properties file:
src=android-support-v4.jar
doc=doc\\android-support-v4_doc
and my dir looks like this:
android-support-v4.docs.zip
android-support-v4.jar
android-support-v4.jar.properties
doc
close project and open, and it all works for me.
I generated this one based on wnafee's answer:
https://dl.dropboxusercontent.com/u/31272696/android-support-v4.zip
I went through all of these solutions and none of them worked. Here is what I did to get it to work:
Navigate to the following folder:
D:\\Android-SDK\android-sdk-windows\extras\android\support\v4
Run the command:
javadoc -d docs -sourcepath src\java -subpackages android.support.v4
In your project's libs directory, create a file called android-support-v4.jar.properties
In the properties file, add the following lines (change the path to match yours):
doc=D:\Program Files\Android-SDK\android-sdk-windows\extras\android\support\v4\docs
src=D:\Program Files\Android-SDK\android-sdk-windows\extras\android\support\v4\src
In Eclipse, bring up the properties dialog for the Build, then navigate to Java Build Path and select the Libraries tab.
Expand the support library. In my case the path is:
D:\Program Files\Android-SDK\android-sdk-windows\extras\android\support\v4
Select Javadoc location. Click on the Edit button and then select the path to the docs. In my case it was:
file:/D:/Program Files/Android-SDK/android-sdk-windows/extras/android/support/v4/docs/
Close everything, including Eclipse and restart. You should now be able to browse docs in your code.