How to connect source to android.jar

I am new to Android. I work on Windows with the Eclipse IDE. My simple application has a counter that populates a list from a database column. When I click on the spinner Class, the file editor says that the source was not found, and the android.jar file has no source attachment.

I downloaded the source code and put it in this place:

android-sdk-windows\platforms\android-8

Then I attached this source with the following steps:

right-click project => build path => configure build path => libraries => source attachment => specify the path to the source code loaded.

But I had no solution for my debugging. Again, when you click on the spinner, debugging opens that the android.jar file has no source attachment.

+73
android eclipse
Apr 22 2018-11-11T00:
source share
7 answers

To attach the source code for android.jar, you can follow the guide at the link below: http://android.opensourceror.org/2010/01/18/android-source/ Be sure to select the correct version of the platform.

If you encounter difficulties with spinner, try to get an example code and see how it works: http://developer.android.com/resources/samples/get.html

Good luck. :)

Update

This answer is quite outdated, please consider other answers.

+13
Apr 29 '11 at 8:21
source share

Now it is very simple!

Go to Window-> Android SDK Manager and install "Sources for Android SDK".

Now try clicking on the Android control and you will get a normal page with no source. Click "Attach Source" and select an option to select an external folder.

Now go to /home/me/android-sdks/sources/android-16 (or where your SDK is installed, this is the default) and click ok.

He must think and then display the source! Yeah!

+89
Jul 15 '12 at 16:30
source share

If you don't need older API sources, Timmmm is probably your best answer. If you need sources over 14 years old, read ...

In Eclipse just go to

Help → Install New Software

then add update site

http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/

and go through the settings to install it.

This will happily provide sources for all installed API versions and works great for me. There are a few more documents here.

http://code.google.com/p/adt-addons/

find the heading Android Sources

+85
Oct 19 '11 at 11:27
source share

If adding the android-sdks/sources/android-17 folder as an external source does not work (as in my case), you can try to create the android-sdks/platforms/android-17/sources/android-17 folder of copy sources in it and restart eclipse (I have eclipse Juno Service Release 1). Only this way works for me.

Steps for doing this for Android 17:

  • Go to the adroid-sdk installation folder, for me it's d:\ws\android-sdks\
  • Copy the android-17 folder with sources from android-sdks\sources\android-17\ to android-sdks\platforms\android-17\sources\ (you need to create the sources folder here manually), so the final path to the sources should be: android-sdks\platforms\android-17\sources\android-17\
  • restart eclipse, it should automatically connect sources for android-17

UPD: the same solution with symlinks :

Windows Vista + (thanks @ saleemrashid1 ​​for mentioning mklink in the comments):

 1. cd platforms\android-17 2. mklink /D "sources\android-17" "..\..\..\sources\android-17" 

For Unix-based OSs (@Joe comment):

it works great to create a directory and symbolic links "sources / android-XX" to "../../../sources/android-XX":

 mkdir platforms/android-19/sources && ln -s ../../../sources/android-19 platforms/android-19/sources/android-19. 
+14
Dec 25 '12 at 14:25
source share

What worked for me follows the answer found in the Android Murach software. I was stuck trying to debug and tried to work for about 3 hours before moving on to the next page (literally), where he said: "Sometimes Eclipse will display a message not found by the source because ..." (-headdesk -)

My solution was to enable step filtering and add packages that I wanted to skip during debugging. Obviously, Eclipse sometimes goes through all the source code libraries when all you need to do is go through your code. You can work around this by adding packages that you want to skip to the filter. According to Murakh, you simply do this through trial and error, starting with selecting all the packages and adding them. As you continue debugging, you may find that you need to add more packets to the filter.

Specific steps: 1. Enable step filtering; click the button on the toolbar at the top, which looks like this: http://i57.tinypic.com/x3iccp.png 2. Go to the → Settings window, then in the “Settings” dialog box select “Java” → “Debugging” → “Filtering by steps "3. Select all packages. 4. To add additional filters, click "Add Filter", enter the package name with. * At the end, and click "OK." Murach recommends adding these general packages to get started: --android. * --com.android. * --com.google. * --dalvik. * --libcore. * --org.apache. * To add one of these packages, click "Add Filter", enter "android. *" And click "OK." In my Step Filter settings, I had all of the following packages.

android., android.app., com.android., com.google., com.ibm., com.sun., dalvik., java., javax., jrockit., libcore., org.apache., org. omg., sun., sunw. *, ((and this last one is a class, not a package)) java.lang.ClassLoader

I had "Use Step Filters" that were marked at the top of the dialog box, and "Step through filters" checked below. Click Apply, then OK to close the dialog box. It should work.

Good luck

+1
Jun 09 '14 at 19:27
source share

I added appengine sdk and some other sources, and this destroyed my ADT: - (

I saw that for android-16 and android-17, the platform libraries downloaded by the SDK Manager started to go to. / sdk / sources, and before adding appenginge sdk SDK Manager sent the platforms to. / sdk / platforms.

It seems that this change is due to appengine sdk, but for the ADT platform APIs should be available. / sdk / platforms

The. / Sdk / sources path looks like a more general Java location and is probably the "right" path. Thus, Android, as usual, is a problem. I was sure that from now on I needed both. / sdk / sources and. / sdk / platforms, depending on what I compiled.

So, I moved all of. / sdk / sources in. / sdk / platform, deleted. / sdk / sources, and then created the link "cd sdk && Sources ln -s platforms

Now everything works ,-)

0
Jun. 07 '13 at 17:13
source share

For me, the only solution that worked was fsbmain's answer. Kudos to him. I can not comment on his decision because of my low reputation counter. But I want to share my knowledge;)

I am working on windows and do not want to copy the entire source tree to another location. And copy the updates again, etc. Therefore, I used the opportunity to insert a symbolic link, which works with Windows Vista as a charm (or, like Linux). For Linux, you should look at Joe's comment on fsbmain's answer.

Suppose you have a platform in D: \ sdk \ platform \ android-19 . Now you need to create a sources subdirectory and after that create a relative link to the real sources folder.

 D:\sdk\platforms\android-19>mkdir sources D:\sdk\platforms\android-19>cd sources D:\sdk\platforms\android-19\sources>mklink /D android-19 ..\..\..\sources\android-19 

Now restart Eclipse ... Done!

0
Feb 13 '14 at 22:53
source share



All Articles