App won't connect on Android 13 (64-bit architecture)

Issue #11 new
Jorge Alvarez created an issue

Hi, I had an app working fine which was built using Unity 2018. The app would scan, locate and connect to a BLE device perfectly fine, thanks to your plugin.

However, due to Android 13 requirements, I’m trying to build the app for 64-bit architectures. I started the project on Unity 2021 importing all my assets, scripts etc from the old project, facing a lot of problems. I’m stuck now with the plugin not being able to scan for BLE devices.

AndroidJavaException: java.lang.SecurityException: Need android.permission.BLUETOOTH_SCAN permission for android.content.AttributionSource@696233d3: GattService registerScanner

That’s thrown when I use this: bridge.Call("scanForPeripheralsWithServiceUUIDs", serviceUUIDsString);

I’ve tried both adding the BLUETOOTH_SCAN (along with BLUETOOTH_CONNECT and BLUETOOTH_ADVERTISE) permission to the AndroidManifest and requesting those permissions with code in the AndroidBleBridge script but I keep getting the same error.

What am I missing? Is there any incompatibility issue between the plugin and Android 13/arm64 architectures?

Thanks in advance.

UPDATE: The above applied to Mono builds, sorry. When I switch to IL2CPP to build for 64-bit I have to remove/comment out every code related to iOS bridge because I get compilation errors (plugin incompatibility?). The app builds OK and I don’t get the above exception, but the app crashes when it scans for devices… This is the logcat for the error:

2023/03/02 17:12:44.874 21705 21725 Debug BluetoothAdapter isLeEnabled(): ON
2023/03/02 17:12:44.876 21705 21726 Debug BluetoothLeScanner onScannerRegistered() - status=0 scannerId=18 mScannerId=0
2023/03/02 17:12:44.907 21705 21705 Info UnityBleBridge onLeScan() : 1A:84:65:EB:D9:7A, -43, matched filter...
2023/03/02 17:12:44.908 21705 21705 Info UnityBleBridge onUpdatePeripheral() : adding peripheral : 1A:84:65:EB:D9:7A
2023/03/02 17:12:44.909 21705 21705 Debug AndroidRuntime Shutting down VM
0001/01/01 00:00:00.000 -1 -1 Info --------- beginning of crash
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime FATAL EXCEPTION: main
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime Process: com.actionsense.dataglovefromscratch, PID: 21705
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArrayMap;
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at com.startechplus.unityblebridge.ScanRecord.parseFromBytes(ScanRecord.java:188)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at com.startechplus.unityblebridge.Bridge$2.onLeScan(Bridge.java:267)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.bluetooth.BluetoothAdapter$8.onScanResult(BluetoothAdapter.java:4468)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper$1.run(BluetoothLeScanner.java:558)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.os.Handler.handleCallback(Handler.java:942)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.os.Looper.loopOnce(Looper.java:201)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.os.Looper.loop(Looper.java:288)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:7867)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime Caused by: java.lang.ClassNotFoundException: android.support.v4.util.ArrayMap
2023/03/02 17:12:44.909 21705 21705 Error AndroidRuntime ... 12 more

Comments (1)

  1. Log in to comment