Hello,

I have been trying to get Spray client to work on Android, but 
unfortunately I haven't had a lot luck when it comes to setting up a 
suitable Proguard configuration. Akka with Akka IO seems to work with a 
simple TCP client example to communicate to a server using the Proguard 
rules listed below but I would like to use Akka/Spray for HTTP as well.

The error seems to revolve around nested anonymous functions but I don't 
know how to write rules to keep these.

java.lang.NoClassDefFoundError: spray.can.HttpManager$$anonfun$receive$1

Complete error log
https://gist.github.com/tanaka-de-silva/249ef02a742cdc9c0af9

The reference.conf files were excluded and the contents of these(akka, 
spray-util & spray-can) were added to application.conf.

SBT settings

    proguardScala in Android := true

    // Generic ProGuard rules
    proguardOptions in Android ++= Seq(
      "-ignorewarnings",
      "-keep class scala.Dynamic"
    )

    // ProGuard rules for Akka Fragments
    proguardOptions in Android ++= Seq(
      "-keep class macroid.akkafragments.AkkaAndroidLogger { *; }"
    )

    // ProGuard rules for Akka
    proguardOptions in Android ++= Seq(
      "-keepclassmembers class * { ** MODULE$; }",
      "-keep class scala.Option",
      "-keep class scala.Function1",
      "-keep class scala.PartialFunction",
      "-keep class scala.Tuple2",
      "-keep class java.util.concurrent.** { <init>(...); }",
      "-keep class com.eaio.**",
      "-keepclassmembers class com.eaio.**",
      "-keep class akka.**",
      "-keep class akka.** { <init>(...); }",
      "-keep class akka.** { *; }",
      "-keepclassmembers class akka.**",
      "-keep class com.typesafe.config.Config { <init>(...); }",
      "-keep class org.omg.**",
      "-dontskipnonpubliclibraryclassmembers",
      "-dontskipnonpubliclibraryclasses"
    )

    // ProGuard rules for Spray
    proguardOptions in Android ++= Seq(
      "-keep class spray.**",
      "-keep class spray.** { *; }",
      "-keepclassmembers class spray.**",
      "-keepattributes *Annotation*",
      "-keepattributes InnerClasses",
      "-keepattributes EnclosingMethod"
    )

    apkbuildExcludes in Android ++= Seq("reference.conf")

Best Regards,
Tanaka

-- 
You received this message because you are subscribed to the Google Groups 
"scala-on-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to