title: ZeroMQ On Android Java ( Android Studio )
body: <p>I'm trying to program ZeroMQ on my android device and I know how to use ZeroMQ (From C++, Php, .Net , I'm all the time using it.) If I list what I've done until now : </p>
  
  <ul>
  <li>From Dependencies in Android Studio, I added <strong>org.zeromq:jeromq:0.3.5</strong> from maven central search.</li>
  <li>After that, I put a code like the following : </li>
  </ul>
  
  
  
  <pre><code>try
  {
      ZMQ.Context context = ZMQ.context(1);
  
      //  Socket to talk to server
      System.out.println("Connecting to hello world server...");
  
      ZMQ.Socket requester = context.socket(ZMQ.REQ);
      requester.connect("tcp://192.168.2.127:5555");
  
      for (int requestNbr = 0; requestNbr != 10; requestNbr++) {
          String request = "Hello";
          System.out.println("Sending Hello " + requestNbr);
          requester.send(request.getBytes(), 0);
  
          byte[] reply = requester.recv(0);
          System.out.println("Received " + new String(reply) + " " + requestNbr);
      }
      requester.close();
      context.term();
  
  
  }
  catch (Exception e)
  {
     Log.e("Error", "Exception : " + e.getMessage());
  }
  </code></pre>
  
  
  
  <p><strong>When I run this, I got an exception like the following :</strong></p>
  
  <pre><code>01-03 02:20:55.200 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.200 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.200 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.210 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.220 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.230 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.230 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.240 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.250 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.260 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:20:55.270 12562-12562/mia.face.id.zeromq E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method mia.face.id.zeromq.MainActivity.access$super
  01-03 02:21:08.080 12562-12562/mia.face.id.zeromq E/Error: Exception : null
  </code></pre>
  
  <p>I'm actually not new in programming but in Android/Java stuffs. I cannot figure it out how to solve this problem. I searched on the internet however couldnt find something.</p>
  
  <p>If you can help me, I'll be very pleased.</p>
  
  <p>Thanks in advance.</p>
  
  <h2>(Addtion, I forget to include this one : )</h2>
  
  <pre><code>01-03 03:12:58.430 1374-1374/mia.face.id.zmqtestest E/Error: Exception
                                                           android.os.NetworkOnMainThreadException
                                                               at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
                                                               at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:168)
                                                               at libcore.io.IoBridge.sendto(IoBridge.java:490)
                                                               at java.nio.SocketChannelImpl.writeImpl(SocketChannelImpl.java:391)
                                                               at java.nio.SocketChannelImpl.write(SocketChannelImpl.java:349)
                                                               at java.nio.PipeImpl$PipeSinkChannel.write(PipeImpl.java:114)
                                                               at zmq.Signaler.send(Signaler.java:121)
                                                               at zmq.Mailbox.send(Mailbox.java:85)
                                                               at zmq.Ctx.sendCommand(Ctx.java:388)
                                                               at zmq.ZObject.sendCommand(ZObject.java:362)
                                                               at zmq.ZObject.sendPlug(ZObject.java:171)
                                                               at zmq.ZObject.sendPlug(ZObject.java:161)
                                                               at zmq.Own.launchChild(Own.java:126)
                                                               at zmq.SocketBase.addEndpoint(SocketBase.java:550)
                                                               at zmq.SocketBase.connect(SocketBase.java:542)
                                                               at org.zeromq.ZMQ$Socket.connect(ZMQ.java:1246)
                                                               at mia.face.id.zmqtestest.MainActivity$1.onClick(MainActivity.java:34)
                                                               at android.view.View.performClick(View.java:4438)
                                                               at android.view.View$PerformClick.run(View.java:18422)
                                                               at android.os.Handler.handleCallback(Handler.java:733)
                                                               at android.os.Handler.dispatchMessage(Handler.java:95)
                                                               at android.os.Looper.loop(Looper.java:136)
                                                               at android.app.ActivityThread.main(ActivityThread.java:5017)
                                                               at java.lang.reflect.Method.invokeNative(Native Method)
                                                               at java.lang.reflect.Method.invoke(Method.java:515)
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
                                                               at dalvik.system.NativeStart.main(Native Method)
  </code></pre>