6

I'm new to Android and I'm attempting to debug an Android app issue (using Eclipse with Android SDK).

I'd like to step into the Android platform code (specifically code in Activity.class, more specifically code in the startActivityForResult() method where the problem is occurring) and I can't seem to properly get Eclipse to find the code for Activity.class so I can step in and see that source. It gives me the ‘Source not Found’ and I've tried attaching android.jar from several places with the ‘Change Attached Source’ button or via the Project Properties but none of these seem to work. (android.jar taken from the adt-bundle/sdk/platforms/android-7 folder as well as a version taken from the prebuilts/sdk/7 folder of the repo.)

I'm building/debugging with the Google APIs 7 (Android 2.1). The project is set to target Google APIs 7 and the Android virtual device is set to that target as well.

I've tried pointing the source attachment to a local directory that contains Activity.java downloaded from the latest repo (frameworks/base/core/java/android).

Do I need to try to get the version of that source directory used for Android 2.1 from the repo? Or is the fact that I'm building with Google APIs 7 (rather than Android open source 2.1) the problem? Or is there some other android.jar I should be pointing to?

5
  • I would advice you to explore another API source code, like API 15 or so, because as far as I know the Android API 7 does not have the sources to download from the Android SDK Manager. Feb 1, 2013 at 15:10
  • I actually found a solution (not sure if it the best or ideal approach though) but it seems to work (found as an answer to a similar question) mkyong.com/android/attach-android-source-code-to-eclipse-ide
    – ggprod
    Feb 1, 2013 at 15:13
  • Awesome! Please answer your own question when you may so people who come here will be able to do the same. Feb 1, 2013 at 15:14
  • I tried but it told me I need to wait for 7h (since my reputation is low).. will answer then (if noone else does sooner)
    – ggprod
    Feb 1, 2013 at 15:16
  • 2
    possible duplicate of How to attach Android source to Eclipse?
    – Mogsdad
    Aug 28, 2015 at 2:47

2 Answers 2

10

If you're using Eclipse, you can go to Help > Install New Software and paste this link: http://adt-addons.googlecode.com/svn/trunk/source/com.android.ide.eclipse.source.update/

This is a plugin which attaches android source on Eclipse, the other way around is a bit complicated and I haven't tried, but you can do it following the URL below.

1
  • thanks.. yah, that does it.. can't upvote your answer though due to my low rep
    – ggprod
    Feb 1, 2013 at 15:30
0

There is another simple way (though this cant be used for API v7)

This method can be used for all APIs that provide Sources.

  1. Download Sources for android SDK for the API.

  2. Goto the sources folder in android SDK and copy the downloaded source . Eg : If you have downloaded source for API 15 , in your sdk there will be folder named sources and in that folder all the downloaded sources will be listed. So copy the corresponding source folder (will be named as android-15 in this case).

  3. Now goto platforms folder -> enter into corresponding API(android-15) folder -> then create a folder named sources -> enter into sources and paste the folder that you have copied earlier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.