Getting Smack working with Android 1.5...


       Micah Caldwell 5 posts since
Jun 16, 2009
I'm trying to build Smack fro...
Getting Smack working with Android 1.5...


So my question is, does someone more knowledgable than me about these things a...
Getting Smack working with Android 1.5...


I pulled the code required for DNSUtil over from the JDK source tree and I'm g...
Getting Smack working with Android 1.5...


strait out of the JDK and am dropping it into Android, but that code is now co...
Getting Smack working with Android 1.5...


Everything is apache licenced, download at http://github.com/rtreffer/asmack

...
Upcoming SlideShare
Loading in...5
×

Getting Smack working with Android 1.5...

876

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
876
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "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.security.sasl javax.security.auth.callback.NameCallback 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 PacketParserUtils.java 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 SASLMechanism.java 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 SASLGSSAPIMechanism.java 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 sun.reflect.misc.ReflectUtil.java 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 jabber.org:5222 I get disconnected with a 503 error. From the looks of it, this is because jabber.org 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 jabber.org 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 http://github.com/rtreffer/asmack Login as rtreffer@googlemail.com 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 @gmail.com to the user name seemed to do the trick. And thanks to treffer, nice work. Generated by Jive SBS on 2010-05-12Z 5

×