SmackAndroid.init()抛出IllegalStateException异常:"无法初始化静态类块" [英] SmackAndroid.init() throws IllegalStateException: "Could not init static class blocks"

查看:246
本文介绍了SmackAndroid.init()抛出IllegalStateException异常:"无法初始化静态类块"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始接触asmack为Android恭维我已经建立了一个Java的即时通信应用程序。经过与越来越ClassNotFound的异常和错误定位我的服务器(尽管地址和端口是正确)我读到有关建议初始化静态类SmackAndroid通话一段时间。
I codeD,如下所示:

I'm starting out with asmack for Android to compliment a Java instant messenging application I have already built. After a while with getting ClassNotFound Exceptions and errors with locating my server (despite the addresses and ports being correct) I read about the SmackAndroid call that was recommended to initialise the static classes. I coded it as follows:

Context context = getApplicationContext();
SmackAndroid asmk = SmackAndroid.init(context);

我addded code,这些线路以我的应用程序建立任何连接XMPP前已但它完全是给了我一个新的错误,我解决不了。

I addded these lines of code to my application before any XMPP connection had been established but it gives me a new error entirely that I cannot solve.

了java.lang.RuntimeException:无法启动活动
ComponentInfo {cit.jordan.portablechatter / cit.jordan.portablechatter.MainActivity}:
java.lang.IllegalStateException:无法初始化静态类块

我使用的是asmack 0.8.2罐子的android 17这里找到: http://asmack.freakempire.de/

I am using the asmack 0.8.2 jar for android 17 found here: http://asmack.freakempire.de/

推荐答案

唯一的例外是在<抛出一href=\"https://github.com/Flowdalic/asmack/blob/master/static-src/custom/org/jivesoftware/smackx/InitStatic$c$c.java#L48\"相对=nofollow> InitStatic code.java:48 ,然后我从另一个用户类似的报告。我一直想知道为什么它适用于大多数用户,但少数。

The exception is thrown at InitStaticCode.java:48 and I got similar report from another user. I always wonder why it works for most users but a few.

您可以尝试删除<一个在的getClass()通话href=\"https://github.com/Flowdalic/asmack/blob/master/static-src/custom/org/jivesoftware/smackx/InitStatic$c$c.java#L34\"相对=nofollow> InitStatic code.java:34 并看看它是否工作。另一个想法,如果你是无法修改或建立aSmack自己,是改变你正在使用的参数上下文的类型:试用 getApplicationContext() getBaseContext 。也许这会有所帮助。

You could try to remove the getClass() call in InitStaticCode.java:34 and see if it works. Another idea, if you are unable to modify and build aSmack for yourself, would be to change the type of context you are using as parameter: Experiment with getApplicationContext() or getBaseContext. Maybe this helps.

我已经进入这个作为 aSmack的问题#33 。也许我找到这个周末解决它的时间。

I have entered this as aSmack's issue # 33. Maybe I find the time to fix it this weekend.

这篇关于SmackAndroid.init()抛出IllegalStateException异常:&QUOT;无法初始化静态类块&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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