Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 4.1: java.lang.NoClassDefFoundError: android.bluetooth.BluetoothManager #3972

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed
Labels

Comments

@SDLBugzilla
Copy link
Collaborator

@SDLBugzilla SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Android (All), All

Comments on the original bug report:

On 2021-01-08 01:40:29 +0000, Jordan Christiansen wrote:

Created attachment 4642
Patch to disable BluetoothManager for old versions of Android

On Android, prior to API version 18 (i.e. Android 4.1 and older) the BluetoothManager API did not exist yet. However, SDL always uses BluetoothManager when Bluetooth is enabled, causing a crash at runtime with the following stack trace:

E/AndroidRuntime: FATAL EXCEPTION: SDLActivity
java.lang.NoClassDefFoundError: android.bluetooth.BluetoothManager
at org.libsdl.app.HIDDeviceManager.initializeBluetooth(HIDDeviceManager.java:377)
at org.libsdl.app.HIDDeviceManager.(HIDDeviceManager.java:153)
at org.libsdl.app.HIDDeviceManager.acquire(HIDDeviceManager.java:36)
at org.libsdl.app.SDLActivity.startNative(SDLActivity.java:260)
at org.libsdl.app.SDLActivity.onCreate(SDLActivity.java:240)
at org.love2d.android.GameActivity.onCreate(GameActivity.java:117)
at android.app.Activity.performCreate(Activity.java:5063)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

SDL should not try to use the BluetoothManager API if the OS is at an API version less than 18.

I attached a patch that simply disables Bluetooth if BluetoothManager is not present. Ideally Bluetooth should still be supported, but I'm not sure if there are any non-BLE devices that we would need to support in a game.

This bug continues from a discussion in Discourse: https://discourse.libsdl.org/t/java-lang-noclassdeffounderror-android-bluetooth-bluetoothmanager/27722

On 2021-01-08 02:23:02 +0000, Sam Lantinga wrote:

Patch added, thanks!
https://hg.libsdl.org/SDL/rev/a8e6474302ea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant