java.lang.IllegalStateException: Not on the main thread 11-05 10:48:56.504: W/System.err(5498): at com.google.j.a.cl.b(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.maps.api.android.lib6.c.br.b(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.maps.api.android.lib6.c.dw.a(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.android.gms.maps.internal.l.onTransact(SourceFile:51) 11-05 10:48:56.505: W/System.err(5498): at android.os.Binder.transact(Binder.java:380) 11-05 10:48:56.505: W/System.err(5498): at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.getCameraPosition(Unknown Source) 11-05 10:48:56.505: W/System.err(5498): at com.google.android.gms.maps.GoogleMap.getCameraPosition(Unknown Source) 11-05 10:48:56.505: W/System.err(5498): at com.reddatura.freecharging_beta.MapView$GetNewPins.doInBackground(MapView.java:241) 11-05 10:48:56.505: W/System.err(5498): at com.reddatura.freecharging_beta.MapView$GetNewPins.doInBackground(MapView.java:1) 11-05 10:48:56.505: W/System.err(5498): at android.os.AsyncTask$2.call(AsyncTask.java:288) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 11-05 10:48:56.505: W/System.err(5498): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 11-05 10:48:56.505: W/System.err(5498): at java.lang.Thread.run(Thread.java:818) thanks Peter for that. SO the problem doesn't seem to be at onPostExecute as I initially thought, but it is the doinbackground, where I want to get the campos variable EDIT3: as Adogeon advised I've put the whole thing in the main loop, but there is this exception, which I was aware, just for the sake why I used asynctask for this...but I am prone to other suggestions 11-05 11:28:06.926: W/System.err(6417): android.os.NetworkOnMainThreadException 11-05 11:28:06.927: W/System.err(6417): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147) 11-05 11:28:06.927: W/System.err(6417): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:249) 11-05 11:28:06.927: W/System.err(6417): at libcore.io.IoBridge.recvfrom(IoBridge.java:553) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.Okio$2.read(Okio.java:113) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.RealBufferedSource.indexOf(RealBufferedSource.java:147) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:94)

Stack Overflow | Citrus | 2 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Android java.lang.IllegalStateException, not on the main thread

    Stack Overflow | 2 years ago | Citrus
    java.lang.IllegalStateException: Not on the main thread 11-05 10:48:56.504: W/System.err(5498): at com.google.j.a.cl.b(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.maps.api.android.lib6.c.br.b(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.maps.api.android.lib6.c.dw.a(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.android.gms.maps.internal.l.onTransact(SourceFile:51) 11-05 10:48:56.505: W/System.err(5498): at android.os.Binder.transact(Binder.java:380) 11-05 10:48:56.505: W/System.err(5498): at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.getCameraPosition(Unknown Source) 11-05 10:48:56.505: W/System.err(5498): at com.google.android.gms.maps.GoogleMap.getCameraPosition(Unknown Source) 11-05 10:48:56.505: W/System.err(5498): at com.reddatura.freecharging_beta.MapView$GetNewPins.doInBackground(MapView.java:241) 11-05 10:48:56.505: W/System.err(5498): at com.reddatura.freecharging_beta.MapView$GetNewPins.doInBackground(MapView.java:1) 11-05 10:48:56.505: W/System.err(5498): at android.os.AsyncTask$2.call(AsyncTask.java:288) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 11-05 10:48:56.505: W/System.err(5498): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 11-05 10:48:56.505: W/System.err(5498): at java.lang.Thread.run(Thread.java:818) thanks Peter for that. SO the problem doesn't seem to be at onPostExecute as I initially thought, but it is the doinbackground, where I want to get the campos variable EDIT3: as Adogeon advised I've put the whole thing in the main loop, but there is this exception, which I was aware, just for the sake why I used asynctask for this...but I am prone to other suggestions 11-05 11:28:06.926: W/System.err(6417): android.os.NetworkOnMainThreadException 11-05 11:28:06.927: W/System.err(6417): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147) 11-05 11:28:06.927: W/System.err(6417): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:249) 11-05 11:28:06.927: W/System.err(6417): at libcore.io.IoBridge.recvfrom(IoBridge.java:553) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.Okio$2.read(Okio.java:113) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.RealBufferedSource.indexOf(RealBufferedSource.java:147) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:94)

    1 unregistered visitors

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Not on the main thread 11-05 10:48:56.504: W/System.err(5498): at com.google.j.a.cl.b(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.maps.api.android.lib6.c.br.b(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.maps.api.android.lib6.c.dw.a(Unknown Source) 11-05 10:48:56.504: W/System.err(5498): at com.google.android.gms.maps.internal.l.onTransact(SourceFile:51) 11-05 10:48:56.505: W/System.err(5498): at android.os.Binder.transact(Binder.java:380) 11-05 10:48:56.505: W/System.err(5498): at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.getCameraPosition(Unknown Source) 11-05 10:48:56.505: W/System.err(5498): at com.google.android.gms.maps.GoogleMap.getCameraPosition(Unknown Source) 11-05 10:48:56.505: W/System.err(5498): at com.reddatura.freecharging_beta.MapView$GetNewPins.doInBackground(MapView.java:241) 11-05 10:48:56.505: W/System.err(5498): at com.reddatura.freecharging_beta.MapView$GetNewPins.doInBackground(MapView.java:1) 11-05 10:48:56.505: W/System.err(5498): at android.os.AsyncTask$2.call(AsyncTask.java:288) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 11-05 10:48:56.505: W/System.err(5498): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 11-05 10:48:56.505: W/System.err(5498): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 11-05 10:48:56.505: W/System.err(5498): at java.lang.Thread.run(Thread.java:818) thanks Peter for that. SO the problem doesn't seem to be at onPostExecute as I initially thought, but it is the doinbackground, where I want to get the campos variable EDIT3: as Adogeon advised I've put the whole thing in the main loop, but there is this exception, which I was aware, just for the sake why I used asynctask for this...but I am prone to other suggestions 11-05 11:28:06.926: W/System.err(6417): android.os.NetworkOnMainThreadException 11-05 11:28:06.927: W/System.err(6417): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147) 11-05 11:28:06.927: W/System.err(6417): at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:249) 11-05 11:28:06.927: W/System.err(6417): at libcore.io.IoBridge.recvfrom(IoBridge.java:553) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37) 11-05 11:28:06.927: W/System.err(6417): at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.Okio$2.read(Okio.java:113) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.RealBufferedSource.indexOf(RealBufferedSource.java:147) 11-05 11:28:06.927: W/System.err(6417): at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:94)

      at com.android.okhttp.internal.http.HttpConnection.readResponse()
    2. Android
      HttpURLConnectionImpl.getInputStream
      1. com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:175)
      2. com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
      3. com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:616)
      4. com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:379)
      5. com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
      6. com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:190)
      6 frames
    3. com.reddatura.serverside
      FreechargingAPI.GetUnitsOnMap
      1. com.reddatura.serverside.FreechargingAPI.ExecuteGET(FreechargingAPI.java:42)
      2. com.reddatura.serverside.FreechargingAPI.GetUnitsOnMap(FreechargingAPI.java:100)
      2 frames
    4. com.reddatura.freecharging_beta
      MapView$1.onMapSettled
      1. com.reddatura.freecharging_beta.MapView$1.onMapSettled(MapView.java:101)
      1 frame
    5. com.reddatura.listeners
      MapStateListener$4$1.run
      1. com.reddatura.listeners.MapStateListener.settleMap(MapStateListener.java:119)
      2. com.reddatura.listeners.MapStateListener$4$1.run(MapStateListener.java:78)
      2 frames
    6. Android Platform
      ActivityThread.main
      1. android.os.Handler.handleCallback(Handler.java:739)
      2. android.os.Handler.dispatchMessage(Handler.java:95)
      3. android.os.Looper.loop(Looper.java:135)
      4. android.app.ActivityThread.main(ActivityThread.java:5221)
      4 frames
    7. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      1 frame