问题
After changing version to Androidx and can not connect to mqtt server. It worked well in other versions than Androidx. Is this a version problem?
My source code and build information is on the link-> I added it when I made the project. AndroidX Artifact has not been mqt communication since then. What is the problem?
My error Logs↓
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
来源:https://stackoverflow.com/questions/59101906/after-changing-the-version-to-androidx-it-does-not-become-mqtt-connect