7

I am trying to create a iOS and Android XMPP chat client using Unity/C#/Mono. I got a fully functional chat client working for iOS using Jabber.net, but it does not work for Android. So does anyone have any idea of a library that works with Unity/C# for Android?

This post discusses Android and XMPP solutions, but have not found any way of connecting this to Unity: Android and XMPP: Currently available solutions

This is my question related to getting Jabber.net working for Android with Unity: Jabber.net on Unity/Android error (No JNI_OnLoad found in /system/lib/libc.so, skipping init)

Community
  • 1
  • 1
Sunkas
  • 9,542
  • 6
  • 62
  • 102
  • i have complied the jabber-net library for mono 2.0. but when i run it in device i am getting this exception. 'ExecutionEngineException: Attempting to JIT compile method' How did you resolve it ? – Basit ZIa Apr 15 '14 at 10:05
  • Don't remember. Could it be related to stripping level or C# version? http://forum.unity3d.com/threads/43038-ExecutionEngineException-Attempting-to-JIT-compile-method – Sunkas Apr 15 '14 at 12:26

2 Answers2

2

Since nobody have answered here I how I solved it:

  1. ASmack for Android in a new Android project in eclipse
  2. Build a custom wrapper for ASmack with the basic public methods for login,logout,send messages et.c.
  3. Extract as jar library.
  4. Import jar into Unity3D
  5. Use Unity3D's AndroidJNI methods to call the public methods of the jar
  6. Callbacks are set inside the Java-wrapper and call with "UnityPlayer.UnitySendMessage()" (classes.jar from Unity app package have to be imported into Eclipse project to compile)
  7. Success!

A bit work is required and takes some time to debug and build, but it does work.

Sunkas
  • 9,542
  • 6
  • 62
  • 102
1

Instead of all this manipulation with ASmack I recommend to use MatriX XMPP SDK. We are using this library for our Unity projects.

And it works on Win, Mac, iOS, Android without any special manipulation. We have only 1 problem with this lib - can't make it work on in WebPlayer

  • Thank you for your answer. It was a long time since I asked this question. I remembered that I emailed MatriX at the time with a few questions and at the time we could not use it since it lacked some requirement. Can't unfortunately remember what. – Sunkas Jul 13 '15 at 06:54
  • 1
    @Sunkas 2 years ago, AFAIK, there was problem with Sockets and Pro license in Unity ) – Suvitruf - Andrei Apanasik Jul 13 '15 at 06:59
  • Is this still working for you? I've been trying to get it running on Android and I get errors about System.EntryPointNotFoundException: getifaddrs – Alejandro Huerta Jan 20 '16 at 19:23
  • 1
    @AlejandroHuerta I can say that it works in stand alone build for sure. I will test it on Android and iOS tomorrow. – Suvitruf - Andrei Apanasik Jan 20 '16 at 20:42
  • @Suvitruf thank you. I'm also using it successfully on on standalone but have had no success with Android. I haven't tested iOS yet. – Alejandro Huerta Jan 20 '16 at 22:46
  • 1
    @AlejandroHuerta I've tested Matrix on iOS. It works. Will try Android later. – Suvitruf - Andrei Apanasik Jan 21 '16 at 20:57
  • Thanks for letting me know – Alejandro Huerta Jan 23 '16 at 05:03
  • @Suvitruf sorry to bother you, did you ever get a chance to test on Android? – Alejandro Huerta Feb 24 '16 at 06:53
  • @Suvitruf do you have any special configuration set? Android version? I've been trying and failing to get sockets working on the few phones i have to test on and have had to resort to using the BOSH transport layer. – Alejandro Huerta Mar 04 '16 at 19:40
  • @AlejandroHuerta nop. But our game only for 5.0+ Android. So, I don't know does it works on older devices. – Suvitruf - Andrei Apanasik Mar 04 '16 at 22:49
  • @Suvitruf I started messing with player settings, the min API level doesn't seem to affect it BUT it seems the problem comes from using Api Compatibility Level .net 2.0 (Not the subset). I can at least progress from here. Thanks for your help! – Alejandro Huerta Mar 04 '16 at 23:25
  • @AlejandroHuerta I am also getting same issue as you suggested in comment, Build running in Unity Editor very well but fails in Android Device with error log : `getifaddrs`. If you have any solution then please help me. Thanks – technerd Jan 04 '17 at 11:31
  • @technerd I never figured out a fix for this issue. I spoke with the devs and they insisted it was an issue on my end. I believe it had something to do with the android version I was running but I'm not longer working on that project so I haven't looked into it recently. – Alejandro Huerta Jan 19 '17 at 22:53