[zeromq-dev] Zyre on Android (JNI)

Pieter Hintjens ph at imatix.com
Thu Jan 7 14:57:55 CET 2016


OK, so thanks to everyone for helping. The problem was due to how
Android looks for shared libraries; if the root .so needs to specify
its dependencies properly. This means adding a target_link_libraries()
in the Cmake script.

I've gotten Zyre to run on Android now; if anyone wants it, the jar
file is on https://github.com/zeromq/zyre/releases/tag/v1.1.0 and the
scripts are in zyre/master.

On Wed, Jan 6, 2016 at 7:02 PM, Pieter Hintjens <ph at imatix.com> wrote:
> Since the JNI code is generated I can do this automatically once I've
> got the right list of libraries to open.
>
> On Wed, Jan 6, 2016 at 6:01 PM, Joe McIlvain <joe.eli.mac at gmail.com> wrote:
>> What Utsav says sounds right, but from what little I remember, it was called
>> `dlopen`.  You need to separately `dlopen` each library yourself (libsodium,
>> libzmq, czmq, zyre).  I remember having to coax Qt into doing this
>> correctly.
>>
>> On Wed, Jan 6, 2016 at 7:07 AM, Utsav Drolia <utsavdrolia at gmail.com> wrote:
>>>
>>> I think you would have to do a “System.loadLibrary()” in the app, for
>>> every C-library the app refers to.
>>> Or is that taken care of in the zyre library itself?
>>>
>>> Utsav
>>>
>>> > On Jan 6, 2016, at 9:20 AM, Arnaud Loonstra <arnaud at sphaero.org> wrote:
>>> >
>>> > Ok, I played with android studio a bit. Djeez, these dependencies fill
>>> > my harddrive faster than I can empty. :S
>>> >
>>> > Anyway, just build a simple app and ran it on a emulator:
>>> > Unfortunately, ZyreTest has stopped
>>> >
>>> > It seems it can't find the czmq libs?
>>> >
>>> > 01-06 15:15:20.295 1257-1257/org.z25.zyretest I/art: Not late-enabling
>>> > -Xcheck:jni (already on)
>>> > 01-06 15:15:20.296 1257-1257/org.z25.zyretest I/art: Late-enabling JIT
>>> > 01-06 15:15:20.701 1257-1257/org.z25.zyretest I/art: JIT created with
>>> > code_cache_capacity=2MB compile_threshold=1000
>>> > 01-06 15:15:23.956 1257-1257/org.z25.zyretest D/AndroidRuntime:
>>> > Shutting down VM
>>> > 01-06 15:15:23.996 1257-1257/org.z25.zyretest E/AndroidRuntime: FATAL
>>> > EXCEPTION: main
>>> >
>>> > Process: org.z25.zyretest, PID: 1257
>>> >
>>> > java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol
>>> > "zsys_handler_set" referenced by
>>> > "/data/app/org.z25.zyretest-1/lib/arm/libzyrejni.so"...
>>> >                                                                     at
>>> > java.lang.Runtime.loadLibrary(Runtime.java:372)
>>> >                                                                     at
>>> > java.lang.System.loadLibrary(System.java:1076)
>>> >                                                                     at
>>> > org.zeromq.zyre.Zyre.<clinit>(Zyre.java:13)
>>> >                                                                     at
>>> > org.z25.zyretest.ZyreTest.onCreate(ZyreTest.java:15)
>>> >                                                                     at
>>> > android.app.Activity.performCreate(Activity.java:6237)
>>> >                                                                     at
>>> >
>>> > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
>>> >                                                                     at
>>> >
>>> > android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
>>> >                                                                     at
>>> >
>>> > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
>>> >                                                                     at
>>> > android.app.ActivityThread.-wrap11(ActivityThread.java)
>>> >                                                                     at
>>> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
>>> >                                                                     at
>>> > android.os.Handler.dispatchMessage(Handler.java:102)
>>> >                                                                     at
>>> > android.os.Looper.loop(Looper.java:148)
>>> >                                                                     at
>>> > android.app.ActivityThread.main(ActivityThread.java:5417)
>>> >                                                                     at
>>> > java.lang.reflect.Method.invoke(Native Method)
>>> >                                                                     at
>>> >
>>> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
>>> >                                                                     at
>>> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
>>> > 01-06 15:15:53.015 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 20.768ms
>>> > 01-06 15:16:49.526 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.354ms
>>> > 01-06 15:16:54.523 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.210ms
>>> > 01-06 15:16:58.523 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.207ms
>>> > 01-06 15:18:08.166 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.199ms
>>> > 01-06 15:18:11.163 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.218ms
>>> > 01-06 15:18:17.163 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.194ms
>>> > 01-06 15:18:19.163 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 10.227ms
>>> > 01-06 15:19:00.201 1257-1264/org.z25.zyretest W/art: Suspending all
>>> > threads took: 25.579ms
>>> >
>>> > Here's my source:
>>> >
>>> > package org.z25.zyretest;
>>> >
>>> > import android.support.v7.app.AppCompatActivity;
>>> > import android.os.Bundle;
>>> > import org.zeromq.zyre.Zyre;
>>> >
>>> > public class ZyreTest extends AppCompatActivity {
>>> >
>>> >     public Zyre znode;
>>> >
>>> >     @Override
>>> >     protected void onCreate(Bundle savedInstanceState) {
>>> >         super.onCreate(savedInstanceState);
>>> >         setContentView(R.layout.activity_zyre_test);
>>> >         znode = new Zyre("AndroidTest");
>>> >         znode.start();
>>> >     }
>>> >
>>> >     @Override
>>> >     public void onDestroy()
>>> >     {
>>> >         super.onDestroy();
>>> >         znode.stop();
>>> >     }
>>> > }
>>> > _______________________________________________
>>> > zeromq-dev mailing list
>>> > zeromq-dev at lists.zeromq.org
>>> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>>
>>> _______________________________________________
>>> zeromq-dev mailing list
>>> zeromq-dev at lists.zeromq.org
>>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>>
>>
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>



More information about the zeromq-dev mailing list