I recently spent some time trying out Scala on Android, with good results. One of the things I wanted to get working on the Android platform was the Akka actor library, unfortunately this was not exactly a simple affair.
The ProGuard tool, which is a necessary part of the Scala-Android toolchain, needs configuration to make Akka work properly. While I found several ProGuard configurations for Akka online, I was not able to get any of them to work with the versions of Scala and Akka I was using. In the end, I had to manually debug the config with a cycle of building my project with Akka code included, then uploading my code to an android emulator. Once the code was running, I would wait for it to crash with a runtime exception, which would tell me what class was missing. I could then update my ProGuard config, rinse, and repeat.
Eventually I ended up with the following ProGuard configuration which allowed me to use use Akka 2.1.0 with Scala 2.10.1 on Android:
-keep class com.typesafe.** -keep class akka.** -keep class scala.collection.immutable.StringLike { *; } -keepclasseswithmembers class * { public <init>(java.lang.String, akka.actor.ActorSystem$Settings, akka.event.EventStream, akka.actor.Scheduler, akka.actor.DynamicAccess); } -keepclasseswithmembers class * { public <init>(akka.actor.ExtendedActorSystem); } -keep class scala.collection.SeqLike { public protected *; } |
I used this code to implement the “Suggest” examples from Ed Burnette’s “Hello Android” book using scala and Akka actors. The code for this project, including the full proguard config I used is on Github.
Thanks for posting this. The
ExtendedActorSystem
constructor really had me stuck. I still don’t understand what’s going on with that, but at least it works the way you have it.