I am making an email application which is giving the error in this question's title. How can I fix this problem? I am giving my codes screenshot if it is helps to find solution.
问题:
回答1:
Seems to be something they intentionally broke in ADT r17. See http://code.google.com/p/android/issues/detail?id=27490#c6.
回答2:
There is an official solution to this:
Allow src/doc attachement for 3rd party jars in libs/
Since those jars are added dynamically through a classpath container, the devs cannot set the source path and the javadoc through Eclipse UI (container don't allow editing those). To fix this, and to make sure that both paths are picked up not only by the current project, but also by other projects (if the current project is a library project), the value is set by a file sitting next to the jar file. The file is name after the jar file, adding .properties at the end. For instance foo.jar -> foo.jar.properties It can currently contain 2 properties: src: relative or absolute path to the source folder (or archive). doc: relative or absolute path to the javadoc.
https://android-review.googlesource.com/#/c/35702/
EDIT: Explanation in Google I/O 2012 video
Example, for Joda-Time 2.1:
cd $PROJECT/libs
touch joda-time-2.1.jar.properties
And insert the following, making sure the path is correct:
src=/Users/josh.oneal/SDKs/joda-time-2.1/joda-time-2.1-sources.jar
doc=/Users/josh.oneal/SDKs/joda-time-2.1/joda-time-2.1-javadoc.jar
You can now right click your project in Eclipse and refresh, then Command / Ctrl + Click a class such as DateTime
to view its source.
回答3:
When you use eclipse, you can fix it by selecting your library project and go to Properties > Order and Export and move your src dependency above the gen dependency. You can also manually edit your .classpath file to do the same. Source attachments should work after you clean this project. Credits for figuring out the solution goes to NightCrawler
回答4:
Notice the workaround in comment 8
http://code.google.com/p/android/issues/detail?id=27490#c8. "Hello, I have solution to problem described in a comment 3:
- Move content from libs folder back to lib because ADT 17 automatically add all jars from libs directory under Android dependencies.
- Add dependencies from your lib directory as normal eclipse dependency (the old way before ADT 17). Link JAR files with their source JAR files or Javadoc.
- In Project properties -> Java build path -> Order and export check all your added dependencies to be included with project class files.
- Select Android Tools > Fix Project Properties"
回答5:
Had the same problem while using javax.mail to access gmail. According to this link (http://stackoverflow.com/questions/6546926/could-not-find-class-error-when-trying-to-upload-a-video-to-youtube-using-the-gd), there seems to be some sort of problem with it and Android.
I solved it by using this JAR files, here : http://code.google.com/p/javamail-android/
回答6:
I finally found the real and most simple solution to this.
THIS IS USING THE IDE, AND WILL ALWAYS WORK. THE SIMPLIEST SOLUTION.
If you have a complex structure where one library project use a library, and that library project is used for your project, and so on. Or in any case... do this to solve this problem:
Import to eclipse the library you want to be able to see the source code for debugging proccess.
Mark the Is Library Option by Right Clicking the project > Propertie > Android
Then go to all the library projects that uses that library, and Right Click the project > Propertie > Android > Add > and select your library.
Then, go to your project and the library project that is in the Project>Properties>Android>Library_name, click remove and add it again, in order to be able to assume the changes in the library project.
And that's all. It's just use the project of the library itself instead of just using the jar of the library you want to see the source code.
回答7:
Also try this one solution: go to project folder and open .classpath
file.
Here re-order classpathentry
in this way
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
First is <classpathentry kind="src" path="src"/>
and second - <classpathentry kind="src" path="gen"/>
. In my case it resolves all problems.