Android and XMPP: Currently available solutions [closed]
Asked Answered
A

7

168

Which XMPP library would be the best choice nowadays for Android development?

  • I've been using the patched Smack library as is suggested in many other questions here in SO. However, that's a patched version of the Smack API from two years ago. And although it generally works well I'm exploring any other, more recent options.

  • I've been looking at the official Smack API and after a little research, it seems it might work just fine nowadays (although I have not tried it yet in a real application).

  • There's also another solution I came across, Beem's aSMACK library. Beem is a fairly new XMPP client for android and from what I understand they are using their own patched version of aSMACK.

  • Finally, there's aSMACK but that too hasn't been updated for quite some time (as the site suggests).

Do you have any other suggestions or can you explain why I should choose one of the above over the rest?

Avigdor answered 22/1, 2011 at 16:27 Comment(16)
What did you go with in the end? I am trying to decide whether to use official smack or not?Evyn
@Tom: I continued using the first option and never changed to a different version because the project development was halted soon after this post. However, I am inclined to use ASmackService in the future, as mentioned below in the answer by Flow, since I like minimal.Avigdor
Just a ping / note, I've re-opened this in favor of the duplicate that caused this to be closed.Neuritis
I think that closing this question is a big mistake. Being involved in XMPP on Android I can tell that is the only reliable and up to date resource when it comes to the question "How can I use XMPP on Android?" on the whole net. By closing it, you take a high quality value from SO. The question was open for over a year without problems and questions that asked the same where closed as duplicates pointing to this question. I don't even see the point in closing it as "not constructive": It's based on a real world problem, involves facts and references. See also upvote and fav count.Lillie
@casperOne Could you explain why the question was closed?Lillie
@Lillie See the close reason below. "Do you have any other suggestions or can you explain why I should choose..." is ultimately not constructive.According
@According I made an suggested edit to allow the question to be re-opened. I think there should be a least one open question about how to add XMPP to Android applications on stackoverflow.Lillie
@Lillie That suggested edit isn't going to get the question reopened; there's no way that you could phrase this that wouldn't make it a list question; list questions are specifically not constructive for Stack Overflow. Stack Overflow is not about maintaining lists, but quality questions and answers (not lists disguised as Q&A).According
@According So there is no way that one could ask "How can I use XMPP in Android applictions?" on stackoverflow? Sorry, but this is ridiculous. By thinking this way, one could close every question on stackoverflow that has more then one answer/possible solution. This question was open for over a year without anybody bothering and is the target of many similar questions closed as exact duplicates. Soon we will have a new question that takes the role of this one. Are you really willing to close all of those questions to come?Lillie
@According The for example here, here and hereLillie
@Lillie If asked in this manner, then yes. BTW, you didn't ask "How can I use XMPP in Android applications?" (which, if you didn't show any effort to show what you've done and the problem you are facing, would be closed as NARQ), you asked a completely different, non-constructive question. If you want, you can bring this up on meta if you want a fuller understanding of why this question was closed (as well as get the community's opinion on it).According
@According Thanks for your patient explanations. It helps me understanding where the problem with stackoverflow is. Maybe I will bring this up on meta, but it seems that this is the majority's opinion and was discussed many times already. It just doesn't feels right, especially since it wasn't closed by votes for years.Lillie
Apart from my need for "How to use XMPP in android"the discussion between "Flow" and "casperOne" is more interesting. I wandered on internet for xmpp and in the end of the day I am here on this post which is providing me more specific informations about libraries I can use for XMPP even after TWO YEARS of OP, is definitely constructive to me and will be to hundreds of newbie for chat apps. "EVENTS" speaks more than "RULES" that "FLOW'S" point of view is correct over this questions closure.Vaccination
It's a common practice people don't give a sht and close a question. like this goo.gl/8OQiPs it is totally unrelated but still closed. so there should be HUGE penalty in terms of deduction of user trust level and points, if some users found guilty of closing some post that should not be closed. Here Admin formed a monopoly and when they see that x has closed it so they don't give a sht and they just hit close maybe because they trust each other and this is the major problem, needs to be addresses otherwise there will some other counter stackoverflow website, who know :-)Generate
@Flow, What's the difference between this thread and https://mcmap.net/q/145368/-good-xmpp-java-libraries-for-server-side-closed/632951 ?Ethiop
Android is not Java. It's just the same language but a different runtime.Lillie
L
108

Smack

Smack is a open-source XMPP client library. Since version 4.1 it runs natively on Android. For more information have a look at the "Smack 4.3 Readme" and see the Smack project page at Ignite Realtime.

Lillie answered 30/3, 2011 at 14:41 Comment(9)
Merged Smack 3.2.0 into asmack. Check out the branches on github :)Lillie
Edited comments > hi all > I am using asmack for developing my xmpp client,I am facing a problem > When i come from 1st time login I start my chatting with user B and receiving messages from user B also that is fine.i switch off my wifi and switch on it again then programatically reconnecting my jabber server and again login my account,after reconnecting I am sending messages to user B that is fine but when user B sending me messages that messages on my side not receiving .I don't know what's is wrong with it.plz guideKennie
hi Flow > how we can merge existing asmack with latest smack ? or it is availabel wherer from I can download asmack with latest smack ?Kennie
@Kennie As stated in my answer, asmack and the used smack branch can be found on github. Make sure to read the README's on github.Lillie
hi you have give some link to understand but now they are not available so do have any example for xmpp chat which work fine..Grory
@Lillie i am using your library to implement XMPP transaction but i dont see BOSHConnection in it , where can i find that ?Heartily
@Grory github.com/meisterfuu/SmackAndroidDemoSloppy
is there anyone to help me about this question ? #33453390Sanjak
So far I have issues with smack + the forums are dead. Still looking for an alternativeTransformism
L
6

I recently stumbled across another open-source solution: jaxmpp2

jaxmpp2 also targets Android (and Java SE). I can't really say anything else about it, because I don't use jaxmpp2 in my Android/XMPP projects. But it looks like a valid alternative to aSmack.

Lillie answered 1/12, 2013 at 10:33 Comment(2)
can you please describe any way to start with , smack library .... this is totally new for me . please make a blog or some libaray_project that guys with normal mind can understand this library properly .Ohmmeter
I found a tutorial on developer.samsung.com/android/technical-docs/… which is especially good, note that there calls for some small modification due to compatibility reasons: https://mcmap.net/q/145370/-asmack-error-xmppconnection-is-abstract-cannot-be-instantiatedEmpirical
T
3

Use qsmack for android

https://code.google.com/p/qsmack/downloads/list

Its the latest build for Android

I have worked on one to one chat, group chat, video transfer, audio transfer, last seen, change registration number... almost complete whats app. I have created lots of plugin on openfire

Tillage answered 14/4, 2014 at 17:4 Comment(8)
@jaspreet ..... which one to use aSmack / qSmack .Ohmmeter
@jaspreet ... any library roject for integrating qsamck in androidOhmmeter
It's all Chinese and no help available.Generate
dropbox.com/s/dnc9nule3hjh08f/qsmack.zip?dl=0Tillage
let me know If you face any issue in itTillage
@Jaspreet, can i make video chat and audio chat using qsmack?Eleanor
no, you needto use sipDroid for thatTillage
@jaspreet Can you plz share some plugins of openfire you created. Actually I am facing message loss problem on network fluctuation in android and trying to make openfire plugin for that. Have you ever created plugin for message loss problem for openfire? It will really help me if you share some of your plugins. You can contact me at [email protected]Pamphlet
A
3

I would like to use libstrophe and jni. Goals to use this is cross platform, simple to use and performance. libstrophe is written in c so, it easy to write android makefile since the dependency is only openssl and expat lib. In my case, I'm using openssl and expat lib from libjingle which already port to android and ios. (Just need to port gyp file to android makefile or IOS project).

Below is my android makefile



    LOCAL_PATH:= $(call my-dir)/../../libstrophe-0.8.7

    SSL_PROJECT_PATH := openssl/libs/android

    include $(CLEAR_VARS)

    LOCAL_MODULE := openssl

    OPENSSL_LIB_NAME := lib$(LOCAL_MODULE).a

    LOCAL_CFLAGS := -DL_ENDIAN \
        -DOPENSSL_THREADS \
        -DPURIFY \
        -DTERMIO \
        -D_REENTRANT \
        -DOPENSSL_NO_HW \
        -DOPENSSL_NO_GOST \
        -DOPENSSL_NO_DTLS1 \
        -DOPENSSL_NO_RDRAND \
        -DOPENSSL_NO_RSAX \
        -Wall -pipe -fno-exceptions -fno-rtti -fstrict-aliasing -mfpu=neon -mfloat-abi=softfp


    OPENSSL_PATH := openssl/openssl
    OPENSSL_PATH_INC := $(LOCAL_PATH)/openssl/openssl

    LOCAL_C_INCLUDES := \
        $(OPENSSL_PATH_INC) \
        $(OPENSSL_PATH_INC)/include \
        $(OPENSSL_PATH_INC)/crypto \
        $(OPENSSL_PATH_INC)/crypto/asn1 \
        $(OPENSSL_PATH_INC)/crypto/evp \
        $(OPENSSL_PATH_INC)/crypto/modes \
        $(LOCAL_PATH)/openssl/config/android \
        $(LOCAL_PATH)/openssl

    LOCAL_ARM_MODE := arm
    LOCAL_CFLAGS += $(LOCAL_C_INCLUDES:%=-I%) -O3 -DANDROID_NDK


    LOCAL_SRC_FILES := \
        // here is openssl file which is defined in gyp

    LOCAL_SHORT_COMMANDS := true

    include $(BUILD_SHARED_LIBRARY)


    include $(CLEAR_VARS)

    STROPHE_PATH := $(LOCAL_PATH)
    EXPAT := expat-2.1.0
    OPENSSL_PATH := openssl/openssl
    OPENSSL_PATH_INC := $(LOCAL_PATH)/openssl/openssl


    EXPAT_SRC_FILES := \
        $(EXPAT)/lib/xmlparse.c \
        $(EXPAT)/lib/xmlrole.c \
        $(EXPAT)/lib/xmltok.c

    COMMON_CFLAGS := \
        -Wall \
        -Wmissing-prototypes -Wstrict-prototypes \
        -Wno-unused-parameter -Wno-missing-field-initializers \
        -fexceptions \
        -DHAVE_EXPAT_CONFIG_H \
        -DLOGGING -DANDROID \



    COMMON_C_INCLUDES += \
        $(LOCAL_PATH)/$(EXPAT)/lib \
        $(STROPHE_PATH) \
        $(STROPHE_PATH)/src \
        $(OPENSSL_PATH_INC) \
        $(OPENSSL_PATH_INC)/include \
        $(OPENSSL_PATH_INC)/crypto \
        $(OPENSSL_PATH_INC)/crypto/asn1 \
        $(OPENSSL_PATH_INC)/crypto/evp \
        $(OPENSSL_PATH_INC)/crypto/modes \
        $(LOCAL_PATH)/openssl/config/android \
        $(LOCAL_PATH)/openssl \
        ../android/jni


    STROPHE_SRC_FILES := src/auth.c \
        src/conn.c \
        src/ctx.c \
        src/event.c \
        src/handler.c \
        src/hash.c \
        src/jid.c \
        src/md5.c \
        src/sasl.c \
        src/scram.c \
        src/sha1.c \
        src/snprintf.c \
        src/sock.c \
        src/stanza.c \
        src/thread.c \
        src/tls_openssl.c \
        src/util.c \
        src/parser_expat.c \
        src/message.c \
        src/presence.c \
        src/roster.c


    JNI_SRC_FILES := ../android/jni/strophe-jni.c

    ifeq ($(TARGET_ARCH),arm)
        LOCAL_SDK_VERSION := 8
    else
        LOCAL_SDK_VERSION := 9
    endif

    LOCAL_ARM_MODE := arm
    LOCAL_SHORT_COMMANDS := true
    LOCAL_SYSTEM_SHARED_LIBRARIES := libc
    LOCAL_SHARED_LIBRARIES := openssl

    LOCAL_SRC_FILES := $(EXPAT_SRC_FILES)
    LOCAL_SRC_FILES += $(STROPHE_SRC_FILES)
    LOCAL_SRC_FILES += $(JNI_SRC_FILES)

    LOCAL_CFLAGS += $(COMMON_CFLAGS)
    LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
    LOCAL_CFLAGS += $(LOCAL_C_INCLUDES:%=-I%) -O3 -DANDROID_NDK
    LOCAL_C_INCLUDES += $(COMMON_C_INCLUDES)


    LOCAL_MODULE:= libnativeclient
    LOCAL_MODULE_TAGS := optional

    include $(BUILD_SHARED_LIBRARY)


Admirable answered 10/3, 2015 at 10:44 Comment(0)
N
1

You can use Tigase JaXMPP Client Library - it's very versatile and you can use it for both JavaSE applications and for Android development. It's actively developed and Tigase Messenger for Android (Play Store) is based on it.

There is a Basic library documentation wiki page with a couple of examples and for details you should refere to javadocs

Norma answered 9/4, 2019 at 21:35 Comment(2)
is this paid. ?Malinin
It's free and open sourceNorma
A
0

Using Smack 4.1 Readme and Upgrade Guide

Using Android studio 2.3, Recently I have implemented a demo in a very simple way.

-> Just Add gradle dependency in app level gradle as below

compile "org.igniterealtime.smack:smack-tcp:4.1.0"

// Optional for XMPPTCPConnection

compile "org.igniterealtime.smack:smack-android-extensions:4.1.0"

-> Configure Connection Configuration
NOTE : Call this in AsyncTask or in other background thread

 XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                    .setUsernameAndPassword("Your Username here", "Your Password here")
                    .setHost("Host name here")
                    .setServiceName("Your service name here")
                    .setPort(Your port number here)
                    .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) //Disable or enable as per development mode
                    .setDebuggerEnabled(true) // to view what's happening in detail
                    .build();

-> Use isConnected() and isAuthenticated()

-> Use ChatManager for add chatListener.

Ailey answered 29/3, 2017 at 10:29 Comment(1)
any idea how to use this with FCM XMPP ?Rubinstein
P
0

You can use QuickBlox1 for free.

It provides XMPP server out of the box with lots of features, you can read about features there http://quickblox.com/developers/Chat

Here is an example how to start using QuickBlox with aSmack library http://quickblox.com/developers/Android_XMPP_Chat_Sample

Pungent answered 31/5, 2017 at 11:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.