Unknown error communicating with server

Tags: #<Tag:0x00007fe21d73ed88>


Hello Team,

We are developing an mobile app where different user will download our app from play store. Once the app is launched they
will allowed to first register (Signup) them-self to Particle Cloud and then it will register(Setup Device) in the Next step.

We get stuck at register process i.e. signup process. We found that there is API available with SignupWithUser method.

Link we refer : https://github.com/particle-iot/spark-sdk-android/blob/master/cloudsdk/src/main/java/io/particle/android/sdk/cloud/ApiDefs.java

We have setup the Client ID and Client Secrete Key into Strings.xml. And in Activity we are writing the below line:

ParticleCloudSDK.getCloud().signUpAndLogInWithCustomer("xxxxxxx@gmail.com", “xxxxxxxxxxx”, OurProductId);

Where xxxxxx is user entered value. Now when we run this line we are getting error of “error : Unknown error communicating with server”.

There is no documentation or example has been given for these.

I am also attaching the snapshot of my code for same.

We are looking for need full information as soon as possible as what steps we are missing.

Thank you!


@ParticleD, or @mstanley are you able to assist?


Since this looks to be an Android SDK video, I’d like to get @jensck_particle expertise on this.

I suspect it may be an API issue, but I’ll let @jensck_particle make that call to hand it off.


@rakeshjiyani if you print the stack trace of the exception being thrown, you’ll see that the error you’re getting is ultimately caused by android.os.NetworkOnMainThreadException.

Most of the methods on ParticleCloud are (very intentionally) blocking calls which hit the network, meaning that you can’t call them from the main thread.

The SDK has been carefully annotated with @WorkerThread for all blocking calls like this, though, so you should be seeing an warning in Android Studio saying something like: Method signUpAndLogInWithCustomer must be called from the worker thread, currently inferred thread is main thread…

If you’re not seeing that error, you’re either working with an outdated version of Android Studio, or you have suppressed this warning. If it’s the latter, I strongly advise against that, since that warning would have saved you from this issue! :slight_smile:

Hope this helps!