4

can any one provide me solution to this error i have searched alot to this problem but failed

i am using eclipse with ADT

with android sdk 2.0.1
OS Microsoft windows VIsta x86

UMAR-MOBITSOLUTIONS
  • 77,236
  • 95
  • 209
  • 278
  • "adroid.jar file is already in it": is it a *source* jar? (when you open it through winzip or 7zip or..., do you see `.java` files in it?). If not, you need to get the source jar, and unzip it in the pre-defined path. If yes, you still need to unzip it in said path. – VonC Jan 14 '10 at 15:38
  • @UMMA: that is when you should to edit the "source attachment" (as shown in the picture) to refer to the proper jar sources or directory sources. – VonC Jan 15 '10 at 08:56
  • @UMMA: http://androidforums.com/android-developers/1045-source-code-android-jar.html should help on the git front. – VonC Jan 15 '10 at 09:58

2 Answers2

6

Does this article "Making Eclipse show Android’s source" (from Malcolm Rowe) help? (for SDK1.5, adapt it for 2.0)

Once you have a source JAR, you’d normally expect to just attach it directly to the library in Eclipse, but that doesn’t work with the Android SDK. Eclipse says:

“The JAR of this class file belongs to container ‘Android 1.5’ which does not allow modifications to source attachments on its entries.”

Which is a roundabout way of saying that the source path is fixed.
If you open up the Eclipse project properties dialog, change to the Java Build Path page and Libraries tab, then expand the ‘Android 1.5’ library container and then the android.jar file (phew!), you’ll see the ‘Source attachment’ option, which shows where the source is expected to be.

eclipse build path dialog

For the Android 1.5 SDK, this is SDK Location/platforms/android-1.5/sources (and presumably similarly for the Android 1.1 target), where SDK Location is the path set in the ‘workspace preferences’ Android page.
Note that the 1.0 SDK (which only supported the 1.0 target, of course) just appends the string sources to the SDK Location, on the assumption that the SDK location ended with a trailing slash. (This should only be something to look out for if you need to target 1.0; I’m pretty sure it was fixed in the plugin provided with the 1.1 SDK.)

There are two ways to put the source JAR into the right place.

  • The conventional way is to create a directory called sources/ under platforms/android-1.5/ (or 1.1), and then unzip the JAR (which is just a ZIP file) into that directory.
  • However, although sources doesn’t have an extension, Eclipse doesn’t actually require it to be a directory, so a simpler way is just to rename your source JAR so that it’s called sources, and move it into the relevant directory.

Once you’ve moved the file or files into the right places, you just need to get Eclipse to take note of it. I found that just restarting Eclipse was enough, but if that doesn’t work you could always try refreshing the project, or closing and re-opening the project via the context menus.

Eclipse Android source

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • guide me little bit more you talked about this path The conventional way is to create a directory called sources/ under platforms/android-1.5/ (or 1.1), and then unzip the JAR (which is just a ZIP file) into that directory. in my case it is E:\Anroid\SDK\android-sdk_r04-windows\android-sdk-windows\platforms\android-2.0.1 and adroid.jar file is already in it or what else i am missing?? – UMAR-MOBITSOLUTIONS Jan 14 '10 at 13:29
  • No, you need to generate your own source JAR based on the Android Open Source Project. Read the full article VonC linked you to. – Christopher Orr Jan 14 '10 at 19:47
  • by doing this that error is gone now but another one is coming.. what you say about it?? Source not found Edit Source lookup path(written on button) – UMAR-MOBITSOLUTIONS Jan 15 '10 at 07:49
  • @UMMA: that is when you should to edit the "source attachment" (as shown in the picture) to refer to the proper jar sources or directory sources. – VonC Jan 15 '10 at 08:51
  • dear friend i am new to java could you please guide me how to obtain proper jar file ?? – UMAR-MOBITSOLUTIONS Jan 15 '10 at 09:24
  • that tutorial saying in order to generate source code of yours you must have installed git i have installed it please guide what should i do next???? – UMAR-MOBITSOLUTIONS Jan 15 '10 at 09:39
0

we can get it follow the first way, detail show:

my android.jar path is:/home/davidbei/developSW/DevTools/androidSDK/android-sdk_eng.davidbei_linux-x86/platforms/android-2.2.1/android.jar

so put the unzip sources folder into /home/davidbei/developSW/DevTools/androidSDK/android-sdk_eng.davidbei_linux-x86/platforms/android-2.2.1/sources, means apache-http,base&dalvik, those three folders in /home/davidbei/developSW/DevTools/androidSDK/android-sdk_eng.davidbei_linux-x86/platforms/android-2.2.1/sources.

that's all.  in windows it is the same, maybe ~~
David Pai
  • 29
  • 2