无法创建ConnectionFactory对象 [英] Failed to create ConnectionFactory object

查看:55
本文介绍了无法创建ConnectionFactory对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Rabbitmq构建一个android聊天应用程序,并且该项目的构建没有任何问题.但是,在创建ConnectionFactory对象时遇到问题.它给了我以下错误

I'm building an android chat app using rabbitmq and the project builds without any issue. However, I'm having an issue in creating ConnectionFactory object. It gives me the following error

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.zabu.kyimoecho.mosaic, PID: 9002
    java.lang.NoClassDefFoundError: com.rabbitmq.client.impl.nio.-$$Lambda$NioParams$NrSUEb8m8wLfH2ztzTBNKyBN8fA
        at com.rabbitmq.client.impl.nio.NioParams.<clinit>(NioParams.java:37)
        at com.rabbitmq.client.ConnectionFactory.<init>(ConnectionFactory.java:153)
        at com.zabu.kyimoecho.mosaic.GenericIdentity.<init>(GenericIdentity.kt:11)
        at com.zabu.kyimoecho.mosaic.Admin.<init>(Admin.kt:9)
        at com.zabu.kyimoecho.mosaic.MainActivity.<init>(MainActivity.kt:10)
        at java.lang.Class.newInstance(Native Method)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

我已经上网了,我遇到的建议并不能解决这个问题.

I've looked online and the suggestions I came across didn't resolve this issue.

我正在使用Android 3.3.2,JDK 8和Rabbitmq 5.6.0.

build.gradle:

build.gradle :

....
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
...
dependencies {
   implementation 'com.rabbitmq:amqp-client:5.6.0'
   .....
}

推荐答案

仅出于参考目的(如果有人遇到类似问题),我通过将build.gradle中的targetSdkVersion从24更改为27来解决了此问题.

Just for the sake of reference (if anybody runs into similar issue), I resolved this issue by changing targetSdkVersion to 27 from 24 in build.gradle.

这篇关于无法创建ConnectionFactory对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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