aSmack error: XMPPConnection is abstract; cannot be instantiated

时光毁灭记忆、已成空白 提交于 2019-12-21 05:17:08

问题


I'm following a tutorial to make a very basic chat app with Android Studio, but I'm getting the error:

Error:(131, 45) error: XMPPConnection is abstract; cannot be instantiated

at the following line:

ConnectionConfiguration connConfig = new ConnectionConfiguration(HOST, PORT, SERVICE);
         XMPPConnection connection = new XMPPConnection(connConfig); 

And I'm also getting some "Unhandled exception" when trying to use XMPPConnection elements.

Also link to the tutorial: LINK


回答1:


Looks like this changed in Smack 4.0.0. The documentation still has not been updated.

And it looks like they will change it again in Smack 4.1:

What was     
Connection connection = new XMPPConnection()
is
XMPPConnection connection = new XMPPTCPConnection()
in Smack 4 and will become
AbstractXMPPConnection connection = new XMPPTCPConnection()
in Smack 4.1

Please see this link: https://igniterealtime.org/issues/browse/SMACK-574

There is also an upgrade guide for SMACK 4.0: https://community.igniterealtime.org/docs/DOC-2703

UPDATE:

Also, looks like the new Smack 4.x libraries will only run with Java 7 and above. Java 6 backwards compatibility is broken.




回答2:


ConnectionConfiguration was changed too.

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
                    .setServiceName("example.org").setUsernameAndPassword("user", "password")
                    .setCompressionEnabled(false).build();


来源:https://stackoverflow.com/questions/23506658/asmack-error-xmppconnection-is-abstract-cannot-be-instantiated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!