skip to Main Content

Kind Stack-overflowers, I am attempting to create an expo react native module in order to use Bluetooth, However I am experiencing a strange issue

Here is the error:

Missing permissions required by intent BluetoothAdapter.ACTION_REQUEST_ENABLE: android.permission.BLUETOOTH_CONNECT

The error occurs around this code:

val enableBtIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
AppActivity?.startActivityForResult(enableBtIntent, this.ACTION_REQUEST_ENABLE);

This error prevents my module from building, However Strangely, When I add this property to my manifest’s The one in the module with filepath: moduleName/manifests/AndroidManifest.xml when I add the necessary permission: as such:

<manifest>
    <uses-permission name="android.permission.BLUETOOTH_CONNECT" />
</manifest>

I recieve a different, Breaking error:
Attribute is missing the Android namespace prefix, How do I fix this? is this a known error?

2

Answers


  1. The uses-permission tag should look like this

    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    

    you were missing "android:" (namespace) before "name"

    also to make sure no more errors occur add the following to you opening manifest tag

    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    

    The Final manifest file should look like:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
    
        <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    
    </manifest>
    
    Login or Signup to reply.
  2. BLUETOOTH_CONNECT is not the right permission to request for enabling Bluetooth. The correct permission for Bluetooth is BLUETOOTH.

        <uses-permission android:name="android.permission.BLUETOOTH" />

    Make sure to include the xmlns:android="http://schemas.android.com/apk/res/android&quot; declaration at the beginning of the manifest tag.

    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-permission android:name="android.permission.BLUETOOTH" />
    </manifest>

    This may solve your issue, let me know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search