Question

So far, the only way I've been able to debug within Eclipse is to use Treeshaker with Scala IDE's buggy 2.8 branch. If I try to build with Scala IDE without Treeshaker, I get ClassNotFound errors per this long thread on scala-on-android.

Ideally I would build with sbt-android and debug within Eclipse, but I've been unable to do so successfully. The closest to debugging an sbt-android project I was able to achieve was to build the sbt-android project with the android:package-debug command, start the executable with the android:start-emulator command, and then connect DDMS to the application's thread.

However, I had breakpoints set that only would have executed after I connected the debugger to the thread, and none of them caused the thread to stop when reached.

Has anyone been able to debug Scala Android code in Eclipse using any other tools besides Treeshaker with Scala IDE based on Scala 2.8?

UPDATE: I'm successfully debugging (not building) in Eclipse after building from the command line with sbt, sbteclipse, and android-plugin.

What I did was to use Eclipse's new Android project menu, connect to existing source, and point it to the ./src/main directory. Then Eclipse recognized the Android settings, and DDMS recognized the task as belonging to the Eclipse Android project.

I also had to reconfigure the Eclipse project's Java build path source folders by removing the src folder from the build path and adding the ./scala folder. Then I had to restart Eclipse to add breakpoints to the Scala file.

Here's some interesting discussion about the difficulties building and debugging Android applications using Eclipse.

Was it helpful?

Solution

In general debugging Scala code running on Android using Eclipse works well and behaves more or less like debugging Scala on regular (non-Android) applications.

I use sbt with sbt-android and android:start-emulator or android:start-device.

Depending on whether I need to debug the application startup, I set the option to wait for the debugger in the developer settings on the device or emulator. To do this, run "DevTools" / "Development Settings". Select your application and check "Wait for Debugger".

Then you have to select the process to debug in DDMS. Make sure the debug port is shown, and then connect with the Eclipse debugger.

A potential cause for the debugger not installing the breakpoints is that the source code line has no direct equivalent in byte code. For comprehensions come to mind.

OTHER TIPS

Using AndroidProguardScala, I am successful in debugging, using scala 2.10 and Eclipse 3.7 It also deals with for comprehensions as the usual plugin. See the detailed answer there:

Eclipse, Android, Scala made easy but still does not work

The only missing feature is the new scala debugger in the latest scala eclipse plugin, which is not yet integrated. So for example, to debug a map, you will have to go though files such as Map.scala, ArrayBuffer.scala, Object.scala, and so on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top