Re: Dispatch on Android

134 views
Skip to first unread message

Nathan Hamblen

unread,
May 30, 2013, 12:16:24 PM5/30/13
to Ricky Elrod, dispatc...@googlegroups.com
On 05/30/2013 12:39 AM, Ricky Elrod wrote:
> Hi,
>
> I'm currently writing an Android app in Scala, and I was looking to use
> Dispatch to interact with some API endpoints. I saw the release notes
> for 0.10.0 which mention Android and I assumed that this meant it worked
> fine, but I'm running into some issues.
>
> When I try to make a request, my app crashes with this traceback:
>
> https://gist.github.com/CodeBlock/0f9073bcada663d9cab8

Hm, that's the same one that was reported originally I think:
https://groups.google.com/forum/?fromgroups#!topicsearchin/dispatch-scala/android/dispatch-scala/9HhwtHrM0Is

And then Nolan says it was working in ahc 1.7.11:
https://groups.google.com/forum/?fromgroups#!topicsearchin/dispatch-scala/android/dispatch-scala/S-g4MkwiCZw

Which is the version that dispatch 0.10.0 depends on:
http://repo1.maven.org/maven2/net/databinder/dispatch/dispatch-core_2.10/0.10.0/dispatch-core_2.10-0.10.0.pom

So I'm surprised you're seeing the same problem. You could try upgrading
to dispatch 0.10.1 which uses a newer version of ahc, tho given the
information we have that is unlikely to help.

Maybe Nolan can chime in here?

Nathan

Ricky Elrod

unread,
May 30, 2013, 1:08:10 PM5/30/13
to dispatc...@googlegroups.com, Ricky Elrod
Just tried using 0.10.1, seeing the same traceback. :(

If there's any other information I can provide that would make it easier to debug this,
let me know. I'm more than happy to provide anything I can.

-Ricky

Nolan Darilek

unread,
Jun 2, 2013, 4:37:50 PM6/2/13
to dispatc...@googlegroups.com
Here is how I'm initializing Dispatch on Android; let me know if this fixes your issue.

    import com.ning.http.client._
    new providers.netty.NettyAsyncHttpProvider(
      new AsyncHttpClientConfig.Builder().build
    )

Wondering if there is a way to detect running under Android, then run this code by default so Dispatch just works everywhere?
--
You received this message because you are subscribed to the Google Groups "Dispatch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dispatch-scal...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
!DSPAM:51a7877b158738979516561!

Ricky Elrod

unread,
Jun 2, 2013, 9:11:54 PM6/2/13
to dispatc...@googlegroups.com
Well, that did get me a step closer.

I'm now running into an issue where anything I do with Dispatch is,
according to Android, running on the main thread.

I have a library I wrote to interact with an API for a service.

In one of the methods, I do this:
https://gist.github.com/CodeBlock/03a2f11cdd8b6ddd3d3d

...which both the REPL and Scaladoc say returns a
Future[APIResults[Package]], as expected.

Since everything is happening in the Future, I'm not sure why Android is
throwing NetworkOnMainThreadException. It doesn't make any sense to me. :-(

I was wondering if it had to do with the slf4j messages I see when I use
my lib in the REPL (maybe it was trying to look up a hostname or
something), but the traceback doesn't mention that at all, so I'm pretty
confused.

I'm going to assume this isn't a Dispatch thing and I'm just doing
something silly, though.

-Ricky
>> <https://groups.google.com/forum/?fromgroups#%21topicsearchin/dispatch-scala/android/dispatch-scala/9HhwtHrM0Is>
>> <https://groups.google.com/forum/?fromgroups#%21topicsearchin/dispatch-scala/android/dispatch-scala/S-g4MkwiCZw>
signature.asc

Nick Stanchenko

unread,
Sep 27, 2013, 11:15:01 AM9/27/13
to dispatc...@googlegroups.com, ri...@elrod.me
Hi,

I would like to know if you were able to solve this, as I am getting the same NetworkOnMainThreadException.

Kind regards,
Nick
Reply all
Reply to author
Forward
0 new messages