NetworkOnMainThreadException is an exception that is thrown when an Android app tries to make any kind of network communication on the main thread.
As explained in the ANR topic, applications are expected to be responsive. Android has a special exception that is thrown whenever an app tries to make network communication on the main thread. Such problems will not happen with any of the internal libraries as the libraries use an internal pool of threads to make the communication in the background.
In most cases if you do encounter a NetworkOnMainThreadException error then it is likely that you are using a library that you shouldn’t use, assuming that the library doesn’t provide async methods as well.
In some edge cases it makes sense to disable the network on main thread check.
Note that this error will never happen in debug mode as the debugger disables this check.