0

Getting error on Asus, Samsung tablets having OS version 4.4.2 Android Beacon Library version.

Getting below Issue.

I tried updating the library, handling the crash but still able to see below error:-

java.lang.NoSuchMethodError: android.bluetooth.BluetoothAdapter.getBluetoothLeAdvertiser at org.altbeacon.beacon.g.(Unknown Source) at com.mangomirror.app.activity.a.b(Unknown Source) at com.mangomirror.app.activity.HomeActivity$2.a(Unknown Source) at d.g$a$1$1.run(Unknown Source) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method)

Below is my Code:-

public void broadcastAsBeacon(int major, int minor) {
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2(String.valueOf(major))
.setId3(String.valueOf(minor))
.setManufacturer(0x004C)
.setTxPower(txPower)
.setRssi(-89)
.setDataFields(Arrays.asList(new Long[]{0l}))
.build();

    BeaconParser beaconParser = new BeaconParser()
            .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");//
    try {
        beaconTransmitter = new BeaconTransmitter(this, beaconParser);
    }catch(Exception e){
        Log.i("TAG", String.valueOf(e));
    }

    if (beaconTransmitter!=null) {
        beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {

            @Override
            public void onStartFailure(int errorCode) {
                Log.e("Class", "Advertisement start failed with code: " + errorCode);
            }

            @Override
            public void onStartSuccess(AdvertiseSettings settingsInEffect) {
                Log.i("class", "Advertisement start succeeded." + settingsInEffect.getTxPowerLevel());
                Log.i("class", "Advertisement start succeeded." + settingsInEffect);
            }
        });
    }
}

private boolean isBleEnabled() {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();


    if (bluetoothAdapter == null) {
        // Device does not support Bluetooth
    } else {
        if (bluetoothAdapter!=null) {
            if (!bluetoothAdapter.isEnabled()) {
                Intent enableBtIntent = new Intent(ACTION_REQUEST_ENABLE);
                startActivityForResult(enableBtIntent, REQUEST_ENABLE_BLE);
                return false;
            }
        }
    }

    return true;
}

1 Answer 1

0

Transmission is only supported on Android 5.0+. Per the library docs, you must check to see if transmission is supported first by calling

int result = BeaconTransmitter.checkTransmissionSupported(context);

If the device supports transmission, the method returns BeaconTransmitter.SUPPORTED. It may also return:

NOT_SUPPORTED_MIN_SDK
NOT_SUPPORTED_BLE
NOT_SUPPORTED_MULTIPLE_ADVERTISEMENTS (deprecated)
NOT_SUPPORTED_CANNOT_GET_ADVERTISER_MULTIPLE_ADVERTISEMENTS
NOT_SUPPORTED_CANNOT_GET_ADVERTISER
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.