Using the WebThing's Framework on Android/starting a webthingserver

Hey,
I’m developing an Android app using Android Studio and Java for an university project and for that I need to start a WebThingServer to communicate the interactions with the app to the WebThings Gateway but i’m getting the following exception on the “server.start(false)”: NetworkOnMainThreadException. I’ve tried using the doInBackground() method but i still can’t get it to work. Has anyone experienced this kind of error or would have an idea on how i could fix it?

An update on my project: i managed to start the webthingsserver, placing it on the onResume method and threating it on the onPause e onDestroy methods.
Having that said, i’m unnable to start a comunicattion with the gateway.
If anyone has also tried to use the framework on android to implement and start the devices with the app and managed to link them to the gateway and could let me know how they did it would be much apreciatted.