powered by Jive Software

Current state of aSmack (Smack for Android)


#1

aSmack was initiated by Rene Treffer for the buddycloud project. The last available download from him on the aSmack project page on googlecode is from December 2010. Prior to that, the development has been moved to github. But the development stalled there. The last commit is from Aug 2010. This is when I forked the aSmack and Smack repositories on github and started to merge the changes introduced by Smack 3.2.0. I has also added the changes from the upstream. aSmack codebase is now in sync with Smack upstream development.

  • Compiled jars for Android (Make sure to read the README or it wont work!)
  • aSmack build environment
  • README (highly suggesting to read this)

Early alpha development versions of Smack 4.1 are able to run native on Android. Therefore making aSmack obsolete. They also come with support for XEP-198: Stream Management and can be found on maven central. You can read more about it in the

Smack 4.1 Readme and Upgrade Guide

if you want to try those.


#2

Hi Flow,

I passed 1 week trying to understand this sentence in the README:

"In order to work correctly on Android, you need to register Smack’s

XMPP Providers and Extensions manually and init some static code

blocks before you doing any XMPP activty. Calling

SmackAndroid.init(Context) (in org.jivesoftware.smack) will do this

for you."

But really it is difficult for me. Could you please help with a step by step TUTORIAL so that we could understand?

What do you call context ? Are you refering to the Context of a main class activity ?

The truth is that if you could give a simple working example I would be really greatful.

Here is my code but I think I’m not getting it:

############################################

public class MainActivity extends Activity {

public final static String EXTRA_MESSAGE = “com.example.rasaxe.MESSAGE”;

private static Context context;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

context = getApplicationContext();

}

/*public static Context getAppContext() {

return context;

}*/

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.activity_main, menu);

return true;

}

/** Called when the user clicks the Send button */

public void sendMessage(View view) {

// Do something in response to button

Intent intent = new Intent(this, DisplayMessageActivity.class);

EditText editText = (EditText) findViewById(R.id.edit_message);

String message = editText.getText().toString();

intent.putExtra(EXTRA_MESSAGE, message);

SmackAndroid.init(context);

/*AndroidConnectionConfiguration config = null;

try {

config = new AndroidConnectionConfiguration(“jabber.org”, 5222);

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

Connection.DEBUG_ENABLED = true;

Connection conn2 = new XMPPConnection(config);

try {

conn2.connect();

conn2.login(“rasaxe”, “Tahranovitch1”);

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}*/

startActivity(intent);

}

}

################################

Regards,

Tarik


#3

The README mentions IIRC a few open-source Android apps. Studying their code should help you.

The senctence really just means that you need to call SmackAndroid.init(Context) once. Ideally as soon as possible but at least before doing any XMPP activity i.e. Smack API calls. The type of context you use should not really matter, but I think that the application context is the best choice.


#4

I need the smack lib in android and are very happy to found your nice jar, but i get a ClassNotFoundException for the org.jivesoftware.smackx.ServiceDiscoveryManager as soon as I try to init smack with SmackAndroid.init(getApplicationContext()); in my main activity.

That kind of problem comes normaly with a wrong classpath configuration, but in android all you have to do is drop the jar in the libs folder… or so i thought.

Do you have any suggestions to fix this problem?

best regards


#5

Hi Flow,

The latest stable build for Smack is v.4.0.5. Is it possible to port all the latest pure jars to be android compatible or optimized for android use.I will be more than happy to start a new project on github for Smack 4.0.5 android (aSmack).

Please do repost if you already have done something like that.


#6

The latest stable build for Smack is v.4.0.5.
So is aSmack: Index of /4.0.5

Please do repost if you already have done something like that.
That is exactly what aSmack does.


#7

Thanks Flow, Awesome work using it now. However, Do you have any javadoc for asmack-android-8-4.0.5.jar ?


#8

aSmack is in most parts the same code as Smack. So you can look at the Smack javadoc.


#9

smack-android 4.1.0 beta2 is available and BOSH protocol based smack-bosh in combination with jbosh 0.8.0


#10

hi Flow,

i want to know the connection which we establish like below :-

ConnectionConfiguration
config = new ConnectionConfiguration(“192.168.1.4”, 5280);
config.setSecurityMode(SecurityMode.enabled);
config.setReconnectionAllowed(true);
config.setRosterLoadedAtLogin(false);
config.setSendPresence(false);
config.setSocketFactory(SSLSocketFactory.getDefault());

// NOTE: Set to true to launch a window with information about packets
// sent and received
config.setDebuggerEnabled(true);

// -Dsmack.debugEnabled=true
XMPPConnection.DEBUG_ENABLED = true;

XMPPConnection connection = new XMPPConnection(config);
connection.connect();

it is xmpp-websocket or http-bind ?


#11

A post was split to a new topic: Could not resolve xpp3:xpp3:1.1.4c


#12

#13

Closed as aSmack is obsolete: Smack runs on Android now. :slight_smile:

Please create a new post if you want to report an issue or have a question.