如何在Android中使用啪4.1? [英] How to use Smack 4.1 in Android?

查看:157
本文介绍了如何在Android中使用啪4.1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这个答案<一个href="http://stackoverflow.com/questions/22480302/using-your-own-xmpp-server-for-android-chat-app-smack-api">Using你自己的XMPP服务器为Android聊天应用程序(啪API)以了解可用的XMPP的API。拍击似乎是一个不错的选择。

此前掴4.1人有依靠aSmack。 4.1开始,啪会在Android上运行本身。我有一对夫妇的入门的问题。

问题1:
如何我在Eclipse中的Andr​​oid项目包括啪4.1?
这里的说明<一href="https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide">https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide似乎是为Android工作室

问2:
请问code保持不变为Android?
我指的是这里的官方文档:<一href="https://www.igniterealtime.org/builds/smack/docs/latest/documentation/index.html">https://www.igniterealtime.org/builds/smack/docs/latest/documentation/index.html
我想知道的是API的使用是否会留在Android上的一样,太。

解决方案
  

我如何在我在Eclipse Android项目包括啪4.1?

就像你将包括在Eclipse中的Andr​​oid项目的任何其他Java库。通过将的.jar 文件中的库/ 目录,Eclipse中的的Andr​​oid插件和 Android的Ant构建系统将让他们提供给项目的类路径中,包括他们所得到的 .apk文件

与啪4.1的事情是,它在很大程度上模块化。如果你想有一个全功能的拍击在Android上则需要约11 的.jar 文件的东西。现在,你可以用摇篮采用Android工作室,这样包括啪的是简单的添加

 相关性{
  编译org.igniterealtime.smack:咂嘴,安卓4.1.0-RC1
  编译org.igniterealtime.smack:咂嘴-TCP:4.1.0-RC1
  //可选功能
  编译org.igniterealtime.smack:嫌,Android的扩展:4.1.0-RC1
}
 

和摇篮将解决过渡依赖护理。

但是,Android的工作室,还是Android摇篮插件是precise,不支持下载和调试与源附件 1 。这是你显然希望与开源库工作时的东西。

这就是例如我不使用插件摇篮自己的原因之一。我就不能发展啪然后(我也很喜欢的Eclipse,但是这是一个不同的故事)。

于是我们又回到工作与Eclipse /蚂蚁为我们的Andr​​oid项目。该啪4.1自述告诉你使用 MavenToAndroidAnt Python3 的脚本,它会自动下载神器并删除旧的最新情况。如果你把它挂到您的构建过程中,它几乎一样好,用摇篮的也支持源附件

当然,你也可以添加11 的.jar 手动文件,但谁愿意这样做,并有二进制​​文件的源代码库?

  

请问code保持不变为Android?

是的,从4.1啪,啪是啪。所以,如果你是在Android或没有可以参考同样的javadoc,不管。请注意,这也适用于aSmack,因为它啪的只是一个端口到Android。

1:纠正我,如果我错了,但我最后一次尝试是不可能的。这种情况可能会得到在此期间更好。

I was looking at this answer Using your own XMPP server for android chat app (Smack API) to learn about the available XMPP APIs. Smack seems like a good choice.

Prior to Smack 4.1 one had to rely on aSmack. Starting with 4.1, Smack will run natively on Android. I have a couple of "getting started" questions.

Question 1:
How do I include Smack 4.1 in my Android project in Eclipse?
The instructions here https://github.com/igniterealtime/Smack/wiki/Smack-4.1-Readme-and-Upgrade-Guide seem to be for Android Studio

Question 2:
Will the code stay the same for Android?
I am referring to their official documentation here: https://www.igniterealtime.org/builds/smack/docs/latest/documentation/index.html
What I would like to know is whether the usage of the API will stay the same in Android, too.

解决方案

How do I include Smack 4.1 in my Android project in Eclipse?

Like you would include any other Java library in Eclipse Android project. By putting the .jar files in the libs/ directory, the Android plugin of Eclipse and the Android Ant build system will make them available to the projects classpath and include them in the resulting .apk.

The thing with Smack 4.1 is, that it is heavily modularized. If you want a full featured Smack on Android you need something around 11 .jar files. Now, you could use Android Studio using gradle, this way including Smack as is simple as adding

dependencies {
  compile "org.igniterealtime.smack:smack-android:4.1.0-rc1"
  compile "org.igniterealtime.smack:smack-tcp:4.1.0-rc1"
  // optional features
  compile "org.igniterealtime.smack:smack-android-extensions:4.1.0-rc1"
}

and gradle will take care of resolving the transitive dependencies.

But, Android Studio, or the Android gradle plugin to be precise, does not support downloading and debugging with source attachments1. And this is something you clearly want when working with open source libraries.

That's for example one of the reasons I don't use the gradle plugin myself. I could not develop Smack then (I also like Eclipse, but that's a different story).

So we are back at working with Eclipse/Ant for our Android project. The Smack 4.1 README tells you to use the MavenToAndroidAnt Python3 script, which will automatically download the artifacts and delete the old ones on an update. If you hook it into your build process, it's nearly as good as using gradle but also supports source attachments.

Of course you could also add the 11 .jar files manually, but who wants to do that and have binaries in their source repository?

Will the code stay the same for Android?

Yes, starting with Smack 4.1, Smack is Smack. So you can refer to the same javadoc, no matter if you are on Android or not. Note that this was also true for aSmack, since it's just a port of Smack to Android.

1: Correct me if I'm wrong, but last time I tried it was not possible. The situation may got better in the meantime.

这篇关于如何在Android中使用啪4.1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆