Getting Smack working with Android 1.5...


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Getting Smack working with Android 1.5...

  1. 1. Getting Smack working with Android 1.5... Micah Caldwell 5 posts since Jun 16, 2009 I'm trying to build Smack from source using the Android SDK instead of the standard JRE so that I can use Smack in an Android application. The first thing I did was excluded the following, since they require AWT which isn't included in the Android SDK: smack.debugger.LiteDebugger smackx.debugger.EnhancedDebugger smackx.debugger.EnhancedDebuggerWindow Once that is done all that is left with problems are: smack.sasl.SASLGSSAPIMechanism smack.sasl.SASLMechanism smack.util.DNSUtil smack.util.PacketParserUtils These don't work because the Android SDK doesn't include the following: javax.naming java.beans.PropertyDescriptor Generated by Jive SBS on 2010-05-12Z 1
  2. 2. Getting Smack working with Android 1.5... So my question is, does someone more knowledgable than me about these things and how they work think it's possible to remove those dependancies without a massive amount of effort? I would assume some of them have Android equivilants, like javax.naming has to be replaced by something in Android... An alternative, that I'm going to try next, is to see if I can pull out the source for those items from the JRE and rebuild them in my own namespace, then have Smack point to my custom built ones instead of the Java ones. However, I'm expecting that this will lead to the need for many other dependancies and / or there was a reason that the Android SDK left them out. Micah Caldwell 5 posts since Jun 16, 2009 1. Re: Getting Smack working with Android 1.5 SDK. Jun 16, 2009 5:46 AM I got an e-mail from someone who did get Smack working on Android and they did it mostly by just removing stuff from Smack. I'm curious if someone with more knowledge of Smack could let me know what the ramifications of these changes are. In the function parseWithIntrospection now just returns null when called. The reason for this is that PropertyDescriptor isn't available to Android and including of it requires inclusion of most of java.beans, which is pretty substantial from what I can tell. In the member variable sc was removed (which requires a number of other changes, listed here). The assignement of sc in the authenticate functions was removed. In the parameterless version of the authenticate function the try/catch block was completely removed. In challengeReceived the if/else block was removed. The handle function still loops through the callbacks, but it just throws an UnsupportedCallbackException for each now. In props.put call and sc assignment was removed from both authenticate functions. Generated by Jive SBS on 2010-05-12Z 2
  3. 3. Getting Smack working with Android 1.5... I pulled the code required for DNSUtil over from the JDK source tree and I'm going to look into pulling over the SASL code from the JDK as well to see if I can avoid removing all the SASL stuff next. The requirement of java.beans though is something that doesn't look like it will be easy to fix with a few files pulled in from the JDK so if someone can comment specifically on that one (and whether or not I can just comment it out as above) it would be appriciated. Micah Caldwell 5 posts since Jun 16, 2009 2. Re: Getting Smack working with Android 1.5 SDK. Oct 22, 2009 12:59 AM Once again the currently available XMPP clients available on Android devices are pissing me off so I am back to looking into writing my own. I'm planning on picking up where I left off but I would still greatly appreciate it if someone could answer any of my previous questions as it would save me a *lot* of time over answering them myself by pouring over XMPP RFCs and fully understanding the Smack source code. Micah Caldwell 5 posts since Jun 16, 2009 3. Re: Getting Smack working with Android 1.5 SDK. Oct 22, 2009 3:38 AM I was able to pull about 500KB of code over from JDK and build a little supplemental library to extend Android with a few of the missing classes. However, I was still left without java.beans.PropertyDescriptor and if I just have the function org.jivesoftware.smack.util.PacketparserUtils.parseWithIntrospection return null there are a couple of code paths that won't handle things gracefully (and could cause problems later on). What came next I am pretty sure will cause me to burn eternally in hell. I grabbed PropertyDescriptor from the JDK and started bringing over it's dependencies. Once I got to java.beans.Introspector I commented out almost the entire file except the one function called in it and it's dependencies. I also went online and found an open sourced version of and created my own version of it with just the functions being called and their dependencies. So basically I have not only ripped code Generated by Jive SBS on 2010-05-12Z 3
  4. 4. Getting Smack working with Android 1.5... strait out of the JDK and am dropping it into Android, but that code is now completely bastardized beyond recognition. On the plus side, I now have Smack compiling for Android 1.6... the next step is to throw together a basic test case to see if it actually works. If so then I will upload my bastardized DalvikVMAdditionsForSmack.jar along with the source code in case anyone in the future wants to try and get Smack working on Android. Micah Caldwell 5 posts since Jun 16, 2009 4. Re: Getting Smack working with Android 1.5 SDK. Oct 23, 2009 7:28 AM The latest roadblock appears to be that Android doesn't ship with a security provider for SaslClientFactory.DIGEST-MD5. If I disable SASL and try to connect to I get disconnected with a 503 error. From the looks of it, this is because requires SASL... but I could be wrong and using the Smack library incorrectly. Either way, I am able to connect to and exchange XML with on Android 1.6 using Smack but given the new issue I am still roadblocked from actually doing anything with it. I am going to take a little break from Smack and explore some other options tomorrow, but I will try to upload my changes before that so if someone else wants to pick it up they can. treffer 20 posts since Dec 10, 2009 5. Re: Getting Smack working with Android 1.5 SDK. Dec 18, 2009 11:01 AM Hi, I've done exactly the requested patching on smack/trunk. SASL is implementet with apache/harmony class definitions and 2 implementations for Digest-MD5 and PLAIN. BeanInfo was replaced with reflection. DNSUtil was replaced with a xbill based implementation. Generated by Jive SBS on 2010-05-12Z 4
  5. 5. Getting Smack working with Android 1.5... Everything is apache licenced, download at Login as worked, so DNS/SRV, introspection and SASL work. MD5-Digest was tested against another jabber server and worked like a charm. PS: Did I mention the AndroidDebugger to dump all stanzas to logcat? JoeWhite 1 posts since Dec 22, 2009 6. Re: Getting Smack working with Android 1.5 SDK. Dec 22, 2009 8:17 PM Never mind. Adding to the user name seemed to do the trick. And thanks to treffer, nice work. Generated by Jive SBS on 2010-05-12Z 5