更改版本为Androidx后,并没有变成mqtt connect

타터터*_*타터터 3 android mqtt androidx

换版本到Androidx后,无法连接mqtt服务器。\n在Androidx以外的其他版本上都运行良好。\n这是版本问题吗?

\n\n

我的源代码和构建信息位于链接-> 我在制作项目时添加了它。AndroidX Artifact从此不再进行mqt通信。问题是什么?

\n\n

我的错误日志\xe2\x86\x93

\n\n
E/AndroidRuntime: FATAL EXCEPTION: main\nProcess: com.example.adfdffffaaaaaaa, PID: 28371\njava.lang.NoClassDefFoundError: Failed resolution of: \nLandroidx/localbroadcastmanager/content/LocalBroadcastManager;\n    at \norg.eclipse.paho.android.service.MqttAndroidClient.registerReceiver(MqttAndroidClient.java:450)\n    at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:428)\n    at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:358)\n    at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:313)\n    at com.example.adfdffffaaaaaaa.MqttKt.connect(Mqtt.kt:15)\n    at com.example.adfdffffaaaaaaa.MainActivity.onCreate(MainActivity.kt:12)\n    at android.app.Activity.performCreate(Activity.java:7159)\n    at android.app.Activity.performCreate(Activity.java:7150)\n    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)\n    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3001)\n    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3156)\n    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)\n    at \nandroid.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)\n    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)\n    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864)\n    at android.os.Handler.dispatchMessage(Handler.java:106)\n    at android.os.Looper.loop(Looper.java:205)\n    at android.app.ActivityThread.main(ActivityThread.java:6993)\n    at java.lang.reflect.Method.invoke(Native Method)\n    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)\n    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)\n Caused by: java.lang.ClassNotFoundException: Didn\'t find class \n"androidx.localbroadcastmanager.content.LocalBroadcastManager" on path: DexPathList[[zip file \n"/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/base.apk", zip file \n"/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_dependencies_apk.apk", zip \nfile "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_resources_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_0_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_1_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_2_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_3_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_4_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_5_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_6_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_7_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_slice_8_apk.apk", \nzip file "/data/app/com.example.adfdffffaaaaaaa- \nanRxYlYVlgY0rXwazlHcYg==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories= \n[/data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/lib/arm64, /system/lib64, \n/system/product/lib64, /system/vendor/lib64]]\n    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)\n    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)\n    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)\n    at \n org.eclipse.paho.android.service.MqttAndroidClient.registerReceiver(MqttAndroidClient.java:450)\xc2\xa0\n    at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:428)\xc2\xa0\n    at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:358)\xc2\xa0\n    at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:313)\xc2\xa0\n    at com.example.adfdffffaaaaaaa.MqttKt.connect(Mqtt.kt:15)\xc2\xa0\n    at com.example.adfdffffaaaaaaa.MainActivity.onCreate(MainActivity.kt:12)\xc2\xa0\n    at android.app.Activity.performCreate(Activity.java:7159)\xc2\xa0\n    at android.app.Activity.performCreate(Activity.java:7150)\xc2\xa0\n    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)\xc2\xa0\n    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3001)\xc2\xa0\n    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3156)\xc2\xa0\n    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)\xc2\xa0\n    at \n android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)\xc2\xa0\n    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)\xc2\xa0\n    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1864)\xc2\xa0\n    at android.os.Handler.dispatchMessage(Handler.java:106)\xc2\xa0\n    at android.os.Looper.loop(Looper.java:205)\xc2\xa0\n    at android.app.ActivityThread.main(ActivityThread.java:6993)\xc2\xa0\n    at java.lang.reflect.Method.invoke(Native Method)\xc2\xa0\n    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)\xc2\xa0\n    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:884)\xc2\xa0\n    Suppressed: java.io.IOException: No original dex files found for dex location \n /data/app/com.example.adfdffffaaaaaaa-anRxYlYVlgY0rXwazlHcYg==/split_lib_resources_apk.apk\n    at dalvik.system.DexFile.openDexFileNative(Native Method)\n    at dalvik.system.DexFile.openDexFile(DexFile.java:354)\n    at dalvik.system.DexFile.<init>(DexFile.java:101)\n    at dalvik.system.DexFile.<init>(DexFile.java:75)\n E/AndroidRuntime:     at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)\n    at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)\n    at dalvik.system.DexPathList.<init>(DexPathList.java:164)\n    at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)\n    at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)\n    at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)\n    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)\n    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)\n    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)\n    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)\n    at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:733)\n    at android.app.LoadedApk.getClassLoader(LoadedApk.java:816)\n    at android.app.LoadedApk.getResources(LoadedApk.java:1038)\n    at android.app.ContextImpl.createAppContext(ContextImpl.java:2391)\n    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6040)\n    at android.app.ActivityThread.access$1100(ActivityThread.java:208)\n    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)\n            ... 6 more\n
Run Code Online (Sandbox Code Playgroud)\n

小智 5

尝试android.enableJetifier=truegradle.properties文件中设置。如果这不起作用,请尝试添加implementation 'androidx.legacy:legacy-support-v4:1.0.0'build.grade.

这个问题之前已经在下一个链接中解决了,我强烈建议检查它们,特别是 420:

https://github.com/eclipse/paho.mqtt.android/issues/321

https://github.com/eclipse/paho.mqtt.android/issues/420