Source Debugging an Android App Built Against an old Platform but Running on a Newer Device
Sunday, June 03, 2012, Modified: Sunday, June 03, 2012 Refs

For maximum compatibility you might target an old MinSDK version and link against a similarly old android.jar. As a developer, other than during specific testing, you will probably be working on a device with a more up-to-date Android version.

When debugging with Android platform source provided by the Android Source Plugin, the platform version of the source picked up by the plugin will be the same as the version the app is built against, not the version running on the device. Often this works out okay where the source hasn't changed, so it is easy to not worry about it, but sometimes it does matter.

A solution is to point the debugger manually at the right source zip provided by the plugin.

While debugging, click down the stack until you find a class with no source. In the source view for that class click the "Edit Source Lookup Path" button.

Navigate to the source plugin's directory under the Eclipse plugin directory. For example, mine lives here on Linux:

~/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/com.android.ide.eclipse.source_16.0.0.201112171909

Go into the numbered folder corresponding to the API version on the device. For example:

Android 2.3.3 -> 2.3.7 = API 10

Select the "sources.zip" in there.

After hitting OK/Confirm and a short puse, your source view should be loaded up with the right version of the Android sources so you can debug accurately.

Try Buffer, a smarter way to share links and pictures by spreading your tweets and posts out over time. Sign up from this link and we both get extra features.

Buffer
Home :: Items