Android error BluetoothAdapter.getName() on a null object reference

/BluetoothAdapter( 3513): Bluetooth binder is null
W/System.err( 3513): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.bluetooth.BluetoothAdapter.getName()' on a null object reference
W/System.err( 3513):    at com.learnium.RNDeviceInfo.RNDeviceModule.getConstants(RNDeviceModule.java:75)
W/System.err( 3513):    at com.facebook.react.bridge.BaseJavaModule.writeConstantsField(BaseJavaModule.java:452)
W/System.err( 3513):    at com.facebook.react.bridge.NativeModuleRegistry.writeModuleDescriptions(NativeModuleRegistry.java:82)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl.buildModulesConfigJSONProperty(CatalystInstanceImpl.java:358)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl.initializeBridge(CatalystInstanceImpl.java:125)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl.access$200(CatalystInstanceImpl.java:39)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl$1.call(CatalystInstanceImpl.java:96)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl$1.call(CatalystInstanceImpl.java:91)
W/System.err( 3513):    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$1.run(MessageQueueThreadImpl.java:73)
W/System.err( 3513):    at android.os.Handler.handleCallback(Handler.java:739)
W/System.err( 3513):    at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err( 3513):    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
W/System.err( 3513):    at android.os.Looper.loop(Looper.java:135)
W/System.err( 3513):    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:197)
W/System.err( 3513):    at java.lang.Thread.run(Thread.java:818)

2 thoughts on “Android error BluetoothAdapter.getName() on a null object reference

  1. I am also getting this error. Anyone have a solution?

    I have bluetooth permissions added in my AndroidManifest.xml
    <uses-permission android:name="android.permission.BLUETOOTH"/>

  2. try {
          BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
          deviceName = myDevice.getName();
        } catch(Exception e) {
          e.printStackTrace();
        }

    I think we should check if myDevice is not null

    maybe the device does not have bluetooth

Android error BluetoothAdapter.getName() on a null object reference

/BluetoothAdapter( 3513): Bluetooth binder is null
W/System.err( 3513): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.bluetooth.BluetoothAdapter.getName()' on a null object reference
W/System.err( 3513):    at com.learnium.RNDeviceInfo.RNDeviceModule.getConstants(RNDeviceModule.java:75)
W/System.err( 3513):    at com.facebook.react.bridge.BaseJavaModule.writeConstantsField(BaseJavaModule.java:452)
W/System.err( 3513):    at com.facebook.react.bridge.NativeModuleRegistry.writeModuleDescriptions(NativeModuleRegistry.java:82)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl.buildModulesConfigJSONProperty(CatalystInstanceImpl.java:358)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl.initializeBridge(CatalystInstanceImpl.java:125)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl.access$200(CatalystInstanceImpl.java:39)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl$1.call(CatalystInstanceImpl.java:96)
W/System.err( 3513):    at com.facebook.react.bridge.CatalystInstanceImpl$1.call(CatalystInstanceImpl.java:91)
W/System.err( 3513):    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$1.run(MessageQueueThreadImpl.java:73)
W/System.err( 3513):    at android.os.Handler.handleCallback(Handler.java:739)
W/System.err( 3513):    at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err( 3513):    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
W/System.err( 3513):    at android.os.Looper.loop(Looper.java:135)
W/System.err( 3513):    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:197)
W/System.err( 3513):    at java.lang.Thread.run(Thread.java:818)

2 thoughts on “Android error BluetoothAdapter.getName() on a null object reference

  1. I am also getting this error. Anyone have a solution?

    I have bluetooth permissions added in my AndroidManifest.xml
    <uses-permission android:name="android.permission.BLUETOOTH"/>

  2. Pingback: wigs