简体   繁体   English

Android 4.2.2设备上的java.lang.NoClassDefFoundError

[英]java.lang.NoClassDefFoundError on Android 4.2.2 Devices

I have an Android application and need to implement bluetooth low energy functionality. 我有一个Android应用程序,需要实现蓝牙低功耗功能。 The BLE features should run on devices with Android API Level > 26 (Android 8), but the app should also start on devices with Android > 17 (Android 4.2). BLE功能应在Android API级别> 26(Android 8)的设备上运行,但该应用程序也应在Android> 17(Android 4.2)的设备上启动。 I have tested this app on Android 8 and 4.4 and there are no problems. 我已经在Android 8和4.4上测试了此应用程序,没有问题。 If i let the app run on devices with Android 4.2.2 it crashes just after the start. 如果我让该应用程序在装有Android 4.2.2的设备上运行,则启动后即会崩溃。 Logs look like that: 日志如下所示:

AndroidRuntime: FATAL EXCEPTION: main java.lang.NoClassDefFoundError: android/bluetooth/BluetoothGatt AndroidRuntime:致命异常:main java.lang.NoClassDefFoundError:android / bluetooth / BluetoothGatt

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.bluetooth.BluetoothGatt" on path: /data/app/com.evva.aess.android.programmingdevice-1.apk 原因:java.lang.ClassNotFoundException:在路径:/data/app/com.evva.aess.android.programmingdevice-1.apk上找不到类“ android.bluetooth.BluetoothGatt”

Android project configuration: Android项目配置:

compileSdkVersion = 26
buildToolsVersion = '27.0.3'
minSdkVersion = 17
targetSdkVersion = 26

Also MultiDex is enabled and my main application extends MultiDexApplication. 还启用了MultiDex,我的主应用程序扩展了MultiDexApplication。

Is there a need to config the proguard rules? 是否需要配置Proguard规则? I don't know how to fix that, thank you for any help. 我不知道该如何解决,谢谢您的帮助。

As can be seen in the documentation, BluethoothGatt was added in API level 18: https://developer.android.com/reference/android/bluetooth/BluetoothGatt . 从文档中可以看出,BluethoothGatt是在API级别18中添加的: https : //developer.android.com/reference/android/bluetooth/BluetoothGatt

Your current minSDK is 17. You either have to update your minSDK or find another solution (eg 3rd party lib, etc.) 您当前的minSDK为17。您必须更新您的minSDK或找到其他解决方案(例如,第三方库等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM