Android + ZeroTier SDK

Follow

Comments

14 comments

  • Avatar
    fguerzoni

    Hi joseph.henry, thank you for your post.

    I need some more informations because I cannot get started with android SDK.

    Could you please reply to following:



    1. where is the Makefile which has target 'android_jni_lib'? I cannot find it so I cannot build the libZeroTierOneJNI.so to import in example app. I've imported the android_jni_lib project in AndroidStudio and built it and no NDK compilation was triggered.

    2. I ran 'make all' under SDK root resulting in libztintercept.so which is quite useless because I'd like to experiment direct calls.

    3. Are the known issues solved? I'm eager to start integrating ZT in our project.


    Thanks in advance

    BR

    f

  • Avatar
    Joseph Henry

    Welcome fguerzoni,


    Thanks for your interest! What platform is the host system you're building from? Currently we've only built for Android on OSX. It should build fine on Windows or Linux but I just haven't put that capability into the respective makefiles yet.


    You'll notice that ZeroTierSDK/Makefile calls ZeroTierSDK/make-mac.mk or ZeroTierSDK/make-linux.mk depending on your platform.


    Check out the android_jni_lib section of https://github.com/zerotier/ZeroTierSDK/blob/master/make-mac.mk you can adapt that section to perform the build on whatever system you're using.


    The known issues mentioned in the previous post are resolved, however the Android integration will remain in ALPHA for the time being. We've recently made a few small tweaks to the API for Android so I'd pull that and check out the latest example app. For this integration basic network join/leave and TX/RX capability works but isn't extensively tested.


    Do you mind telling us how you plan on using this in your product? For the earliest adopters we plan on paying close attention to your use cases and making sure everything you need is present and working.


    Thanks.

  • Avatar
    fguerzoni

    Thank you for quick reply.

    Sorry, I forgot to mention the host platform which is linux.

    I'll try to apply your advices and I'll give you feedback.


    I'm available to privately discuss our project with you. I think any kind of collaboration is appreciated.


    BR

    f

  • Avatar
    Joseph Henry

    No problem! If you send an email to joseph.henry@zerotier.com we can get you an invite to our SDK slack channel for more real-time discussion.

  • Avatar
    fguerzoni

    I tried with no luck.

    (I cannot attach files so) please check pastebin for the updated linux makefile:

    http://pastebin.com/cVp9NB29


    I get a cross compiler error for armeabi-v7a arch when compiling OneService.cpp. The compiler doesn't like a couple of __THROW clauses in /usr/bin/ifaddrs.h. I really don't know how to solve the issue. Googling gives little help.

    Please check again pastebin for log (executed makefile with --debug option):

    http://pastebin.com/c1md90VV


    Just to give it a try, I deleted the __THROW clauses from ifaddrs.h file.

    It ends compiling fine, then it blocks again on a linker error:

    jni/../../../../../src/SDK_Sockets.c:462: error: undefined reference to 'zt_bind'

    http://pastebin.com/tc3FgUG5


    could you help please? Thanks

    BR

    f

  • Avatar
    Joseph Henry

    Good morning.


    It looks like each of the errors were from problems we fixed last week. Perhaps the contents of ZeroTierSDK/src haven't been updated. Try pulling the most recent source and it should resolve those issues.


    Otherwise, if you'd rather manually fix them, you can do the following:



    • Surround the include of ifaddrs.h in zerotierone/service/OneService.cpp with #if !defined(__ANDROID__) ... #endif

    • Relevant fix for zt_bind() reference error: commit


    As a side note, the SDK works with Android NDK r10e but there are known incompatibilities with r12b. We'll be addressing those soon.

  • Avatar
    fguerzoni

    You are right.

    After git update the build was successful. Now I've got the 'libZeroTierOneJNI.so' to test.

    Thank you very much.

    BR

    f

  • Avatar
    fguerzoni

    I played with exampleApp which basically works.

    I have the following questions:



    1. is there an exposed api that let me know the ZT local address of android device? This is mandatory to let an external client connect to the android device which binds a local port. The only way I found is to connect as a client to an external server and have the remote address returned.

    2. zt_bind seems not working to me. I always got a fatal error when calling it:

      08-05 00:49:59.120 8185-8185/com.example.joseph.example_app V/ZTSDK: zt_bind(): fd = 65

      addr = 28.224.244.130

      port=8081

      08-05 00:49:59.122 8185-8239/com.example.joseph.example_app V/ZTSDK: phyOnUnixData(0x552535d8), len = 1423308776

      08-05 00:49:59.122 8185-8239/com.example.joseph.example_app V/ZTSDK: <sock=0x552535d8> RPC: (pid=1423308776, tid=1470350999, timestamp=<6%U, cmd=876228656)

      08-05 00:49:59.123 8185-8239/com.example.joseph.example_app V/ZTSDK: phyOnUnixData(0x552535d8), len = 1423308776

      08-05 00:49:59.123 8185-8239/com.example.joseph.example_app V/ZTSDK: <sock=0x552535d8> RPC_BIND

      08-05 00:49:59.123 8185-8239/com.example.joseph.example_app A/libc: Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 8239 (Thread-5000)


    3. is there an exposed api to know if the connection is p2p or relayed? when testing with linux pc I have traceroute that lists the hops.

    4. If the exampleApp closes by accident without leaving the network, I noticed there's no easy way to reconnect to server. The android device keeps cycling on ZT_connect which always returns -1. The only way is to manually uninstall the app and reinstall it. Am I wrong?


    Thanks in advance

    BR

    f

  • Avatar
    Joseph Henry

    Sure, here's the current state of those issues:



    1. I started work on this feature last night and it'll be in the next update today actually.

    2. As of last night that issue is fixed.

    3. This knowledge isn't something the SDK currently exposes. But, I can see what I can do about this.

    4. I think you're correct, if it crashes unexpectedly (which the latest code shouldn't as often) then a reinstall might be necessary. I'll look into this today and give you an update.

  • Avatar
    Janjaap Bos

    @fguerzoni to get info about the connection, you can just query the http api at the zerotier service port, using the authtoken and the port values in the zerotier directory.

  • Avatar
    fguerzoni

    Hi JJ,

    thank you for your kind reply.

    My questions arise in the SDK context + direct calls. ZT service is embedded inside ZT stack and I think is not freely addressable except using exposed api.

    I really don't know how to alternatively interact with it.

    Could you please give more details about your solution to let me do the try?

    BR

    f

  • Avatar
    Joseph Henry

    With the latest code, you can call zt_get_addresses(nwid_string) which will return an ArrayList of Strings formatted standard CIDR notation.


    This call will return -1.-1.-1.-1/-1 in the event that it is called before the ZeroTier service has been fully initialized.

  • Avatar
    fguerzoni

    I confirm it works nice. Thank you.

  • Avatar
    naren5a1

    Hi @joseph-henry,

    I downloaded the latest code from GitHub, I am getting following errors while making.

     

    Make environment - macOSSierra

    Version - 10.12

     

    The following build commands failed:

    CompileC /Users/ganeshv/Library/Developer/Xcode/DerivedData/ZeroTierSDK_Apple-gyictsojzapyxwcfpudrjjmiuzpg/Build/Intermediates/ZeroTierSDK_Apple.build/Release/ZeroTierSDK_OSX.build/Objects-normal/x86_64/service.o /Users/ganeshv/Desktop/ZeroTier/ZeroTierSDK-master/src/service.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler

    (1 failure)

    make: *** [osx_app_framework] Error 65

Please sign in to leave a comment.