Dispatch on Android... has someone done it yet?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Dispatch on Android... has someone done it yet?

sippndipp
Hi,

I'm trying to run dispatch on Android. I created a project with eclipse added a vary of scala and android-scala dependencies following this tutorial:

http://www.akshaydashrath.com/2009/10/scala-and-android.html

workes fine so far. Then I checked out dispatch using git and added some of the scala files to a freshly created dispatch package.

Sadly I have some dependency troubles as importing dispatch._ seemingly leaves out the :/ function. Maybe this is a bug within eclipse scala plugin. I will try a home grown build process.

Any help on that would be superawesome.

Cheers

Sebastian
--
http://twitter.com/sippndipp/scala-on-android/members
Reply | Threaded
Open this post in threaded view
|

Re: Dispatch on Android... has someone done it yet?

n8han
Administrator
I think this is more of a build problem than a Dispatch problem. :) If have a working sbt project you can use this Eclipse plugin to get all the Dispatch dependencies into Eclipse:

And then, I think if you had a Dispatch project working in Eclipse you could follow those other instructions to get link to build for Android. I can't support you too much on this course, maybe someone else can!

The way I'm going to try is through the Android plugin for sbt:

Nathan

On Nov 16, 2009, at 4:44 PM, sippndipp [via Databinder] wrote:

Hi,

I'm trying to run dispatch on Android. I created a project with eclipse added a vary of scala and android-scala dependencies following this tutorial:

http://www.akshaydashrath.com/2009/10/scala-and-android.html

workes fine so far. Then I checked out dispatch using git and added some of the scala files to a freshly created dispatch package.

Sadly I have some dependency troubles as importing dispatch._ seemingly leaves out the :/ function. Maybe this is a bug within eclipse scala plugin. I will try a home grown build process.

Any help on that would be superawesome.

Cheers

Sebastian
--
http://twitter.com/sippndipp/scala-on-android/members



View message @ http://n2.nabble.com/Dispatch-on-Android-has-someone-done-it-yet-tp4014913p4014913.html
To start a new topic under Dispatch, email [hidden email]
To unsubscribe from Dispatch, click here.


Reply | Threaded
Open this post in threaded view
|

Re: Dispatch on Android... has someone done it yet?

n8han
Administrator
Hi, just reporting in that I'm having limited success with the sbt plugin. Actually, the plugin is great, it's just that proguard * dalvik is a tough platform for Scala to please. scalac implements some static (to Scala) forms with reflection, so proguard can't detect them, and on top of that dalvik is not even supposed to be a fully compliant jvm so a few of Scala's tricks just do not work. Libraries that use Scala fully, like Dispatch and lift-json, are going to require either some internal adjustments or some very complex proguard configuration. This is the main reason that I'm interested in proceeding with the sbt plugin, because we can solve those problems there instead of within plugins tied to a particular IDE.

When I have something worth sharing, I will!

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Dispatch on Android... has someone done it yet?

n8han
Administrator
I should correct my link, the plugin hub is now:
http://github.com/jberkel/android-plugin
Reply | Threaded
Open this post in threaded view
|

Re: Dispatch on Android... has someone done it yet?

n8han
Administrator
All systems are go! I'm using a basic project setup by the plugin's script, and my project definition looks like this specifically:

class TheProject(info: ProjectInfo) extends AndroidProject(info: ProjectInfo) {    
  override def androidSdkPath = Path.fromFile("/Users/nathan/Programming/android-sdk-mac/")
  override def androidPlatformName="android-2.0"

  val databinder_net = "databinder.net repository" at "http://databinder.net/repo"
  lazy val meetup = "net.databinder" %% "dispatch-meetup" % "0.6.4-SNAPSHOT"
  override def proguardOption = """
    |-keep class dispatch.** {
    |  public scala.Function1 *();
    |}
    |-keep class ** extends dispatch.Builder {
    |  public ** product();
    |}
""".stripMargin
}

Perhaps that will be helpful for anyone following along. I'm afraid that tweaking per-app proguard settings is going to be a way of life for all of us Scala programmers targeting android. When this app (which is going to be a photo taker for Meetup) is far enough along I'll make its repository public.

The main point of friction was lift-json's case class extractor, which just can not survive in a proguard * dalvik world (it relies heavily on reflection, and in more recent versions, paranamer reflection). So I backtracked and made an interface similar to what I did for the original dispatch-json, but it came out better this time (also lift-json is an excellent foundation). Essentially, you define API extraction functions in shorthand and then combine and apply those explicitly to extract data. I'm using this for the Meetup interface and may later switch over some of the others.

And yeah, it all works on my Droid. B)

Nathan
Reply | Threaded
Open this post in threaded view
|

Re: Dispatch on Android... has someone done it yet?

n8han
Administrator
Snapup is the app: http://technically.us/git?p=snapup.git;a=summary

It's for taking photos of a Meetup and uploading them to its photo gallery. The app first acquires oauth tokens by going to the browser if necessary, then it presents a list of events from your Meetup calendar. When you select an event it immediately goes into the photo app. If it comes back with a photo, you're asked to enter a caption and then the app tries to upload the photo. It fails! Because photo upload support has not been released on the server side yet. But that will work soon.

Nathan