android studio 编写MQTT 出现 java.lang.NoClassDefFoundError
android studio 编写MQTT 出现 java.lang.NoClassDefFoundError
使用安卓编写Mqtt程序时,Mqtt一连接服务器就报错,错误信息
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/localbroadcastmanager/content/LocalBroadcastManager;
显示如图
可是我的整个工程一点红色的报错都没有
调试发现程序卡在了 Mqtt要连接服务器的时候。调试也没出什么结果。查网上也没找到什么解决方法,讲得最多的就是缺少了依赖。
后来经过我多次修改依赖的情况下,程序终于对了,没有闪退了。
可是我至始至终没用到 gridlayout。查询官网给出的demo,依赖如下:
也没找出原因。
不过,如果你也遇到了跟我同样的问题,你不妨尝试也加一下这个依赖
dependencies {implementation fileTree(dir: 'libs', include: ['*.jar'])implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"implementation 'androidx.appcompat:appcompat:1.1.0'implementation 'androidx.core:core-ktx:1.2.0'implementation 'androidx.constraintlayout:constraintlayout:1.1.3'implementation 'com.google.code.gson:gson:2.8.5'implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.1.1'implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'testImplementation 'junit:junit:4.12'androidTestImplementation 'androidx.test.ext:junit:1.1.1'androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'implementation 'androidx.gridlayout:gridlayout:1.0.0'}
最后一句是关键。
当然了,如果你知道问题出在哪里,欢迎告诉我一下。
最新文章
- JAVA 中的 反射
- AQS(AbstractQueuedSynchronizer)是什么?
- parameterType和@Param注解用法
- KPM算法详解(Next数组)
- 为什么要建议用自增列做主键
- 你了解API测试吗?如何充分的测试一个API?
- Markdown Pad出现HTML渲染错误(HTML Rendering Error)的解决方法,Markdown Pad弹窗报错
- CStdioFile 一些基本用法
- filter过滤器设置URL例外
- JMS(Java Messaging Service)基础
- 【Jmeter 简单使用】
- Swing中如何实现二级联动下拉列表
- 两种模块化语法(module.exports,exports,requireexport,import)
- 新手小白大学生,在宿舍做短视频自媒体,两个星期收益1700多
- 分部积分法的一些特殊方法
- PTA解题
- java内存可视化
- 视频编解码 — H264结构
- HTML中的JavaScript——<script>
- Lock锁(重点)