com.mongodb.MongoException: android.os.NetworkOnMainThreadException


Solutions on the web2

Solution icon of stackoverflow
android.os.NetworkOnMainThreadException

Solution icon of stackoverflow
android.os.NetworkOnMainThreadException

Stack trace

com.mongodb.MongoException: android.os.NetworkOnMainThreadException
	at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:125)
	at com.mongodb.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:46)
	at com.mongodb.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:366)
	at com.mongodb.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:94)
	at com.mongodb.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:80)
	at com.mongodb.connection.DefaultServer.getConnection(DefaultServer.java:69)
	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:86)
	at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:184)
	at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:177)
	at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:141)
	at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:72)
	at com.mongodb.Mongo.execute(Mongo.java:747)
	at com.mongodb.Mongo$2.execute(Mongo.java:730)
	at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:482)
	at com.mongodb.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:277)
	at com.sujithsizon.lzlogin3.LoginActivity.yalla(LoginActivity.java:224)
	at com.sujithsizon.lzlogin3.LoginActivity$3$1.onCompleted(LoginActivity.java:99)
	at com.facebook.GraphRequest$1.onCompleted(GraphRequest.java:304)
	at com.facebook.GraphRequest$5.run(GraphRequest.java:1368)
	at android.os.Handler.handleCallback(Handler.java:615)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4745)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
	at dalvik.system.NativeStart.main(Native Method)
Caused by: android.os.NetworkOnMainThreadException
	at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
	at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
	at libcore.io.IoBridge.connectErrno(IoBridge.java:144)
	at libcore.io.IoBridge.connect(IoBridge.java:112)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
	at java.net.Socket.connect(Socket.java:842)
	at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50)
	at com.mongodb.connection.SocketStream.open(SocketStream.java:58)
	at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114)
	at com.mongodb.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:46)
	at com.mongodb.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:366)
	at com.mongodb.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:94)
	at com.mongodb.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:80)
	at com.mongodb.connection.DefaultServer.getConnection(DefaultServer.java:69)
	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:86)
	at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:184)
	at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:177)
	at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:141)
	at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:72)
	at com.mongodb.Mongo.execute(Mongo.java:747)
	at com.mongodb.Mongo$2.execute(Mongo.java:730)
	at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:482)
	at com.mongodb.MongoCollectionImpl.insertOne(MongoCollectionImpl.java:277)
	at com.sujithsizon.lzlogin3.LoginActivity.yalla(LoginActivity.java:224)
	at com.sujithsizon.lzlogin3.LoginActivity$3$1.onCompleted(LoginActivity.java:99)
	at com.facebook.GraphRequest$1.onCompleted(GraphRequest.java:304)
	at com.facebook.GraphRequest$5.run(GraphRequest.java:1368)
	at android.os.Handler.handleCallback(Handler.java:615)
	at android.os.Handler.dispatchMessage(Handler.java:92)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4745)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

6 times, 5 months ago
6 times, 7 months ago
7 times, 7 months ago
4 times, 8 months ago
2 times, 10 months ago
38 more bugmates