androidtabletaltbeacon

Error E/BeaconTransmitter: Cannot start advertising due to exception with Android 5.5.1 and Samsung T295 tablet


please, help me to solve this problem:

Problem: I have an Android App using altbeacon library sample to transmit as beacon using tablet ( version 2.16.3 is required to my app,(i cant use newer versions because AndroidX requirements), and using this sample https://altbeacon.github.io/android-beacon-library/samples.html but this same code runs perfectly on Android 9 with device Samsung SM-T295, but causes following error on Android 5.1.1 with device samsung SM-T285.

** This is a complete stacktrace from lib: **

E/BluetoothAdapter: bluetooth le advertising not supported
E/BeaconTransmitter: Cannot start advertising due to exception
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeAdvertiser.startAdvertising(android.bluetooth.le.AdvertiseSettings, android.bluetooth.le.AdvertiseData, android.bluetooth.le.AdvertiseCallback)' on a null object reference
        at org.altbeacon.beacon.BeaconTransmitter.startAdvertising(BeaconTransmitter.java:213)
        at org.altbeacon.beacon.BeaconTransmitter.startAdvertising(BeaconTransmitter.java:159)
        at org.altbeacon.beacon.BeaconTransmitter.startAdvertising(BeaconTransmitter.java:149)

Android version with error: 5.1.1

Device type with error: Samsung SM-T285 (Tablet)

** My code (from oficial sample page) : **

Beacon beacon = new Beacon.Builder()
        .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
        .setId2("1")
        .setId3("2")
        .setManufacturer(0x0118)
        .setTxPower(-59)
        .setDataFields(Arrays.asList(new Long[] {0l}))
        .build();
BeaconParser beaconParser = new BeaconParser()
        .setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);
beaconTransmitter.startAdvertising(beacon);

Solution

  • BLE advertising was a new feature with Android 5, and not all hardware at the time supported it. Phone manufacturers had to use special Bluetooth chips with Android-designed extensions that enable advertising by more than one app. The operating system was designed to return an error code to any app that tried to start advertising on a phone that did not have the hardware to support these extensions. The Samsung tablet you describe does not have the required hardware for Android to allow transmission.