0

I've started using Parse recently, and I'm calling Parse.initialize from my applications main activity onCreate method. On my devices it works properly, but some users who tried it are getting android.os.NetworkOnMainThreadException when Parse.initialize is called. See strack trace here: http://crashes.to/s/fbe1eda87a0

I've tried moving the Parse initialization code to AsyncTask, so it won't run on the main UI thread; but this resulted in the app crashing, because another part of the Parse SDK was trying to do an operation but the SDK wasn't initialized yet (I have no control over that part).

I've moved the call to Parse.initialize to Application.onCreate in the meantime, but not sure how that supposed to be better.

Has anyone else experienced this issue and knows how to solve it?

arikfr
  • 3,311
  • 1
  • 25
  • 28
  • 1
    possible duplicate of [android.os.NetworkOnMainThreadException](http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception) – Apoorv Jul 12 '14 at 13:49
  • "but not sure how that supposed to be better" -- that is not better. As the answer that Apoorv links to points out, you need to move your network I/O to a background thread. – CommonsWare Jul 12 '14 at 13:50
  • I know what the exception means and I'm aware of how usually one solves this, but in this case it just caused another issue. This is a Parse specific question, not a general one (I've updated it with additional information). – arikfr Jul 12 '14 at 14:01

1 Answers1

0

Ok, so moving Parse.initialize into the Application.onCreate solved the issue.

arikfr
  • 3,311
  • 1
  • 25
  • 28