gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 23:56:37 27 4
gpt4 key购买 nike

改版本为Androidx后无法连接mqtt服务器。它在 Androidx 以外的其他版本中运行良好。这是版本问题吗?

我的源代码和构建信息在链接上-> I added it when I made the project. AndroidX Artifact has not been mqt communication since then. What is the problem?

我的错误日志↓

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

最佳答案

尝试在 gradle.properties 文件中设置 android.enableJetifier=true。如果这不起作用,请尝试将 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

关于android - 改版本为Androidx后,并没有变成mqtt connect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59101906/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com