| name | Fixing Health Connect Permissions in Expo |
| description | A guide for AI assistants on how to resolve Health Connect permission issues (e.g., SecurityException for record type 11) in an Expo React Native application. |
Fixing Health Connect Permissions in Expo
When an Expo React Native application using react-native-health-connect encounters a SecurityException (e.g., "Caller requires one of the permissions for record type 11") on Android, it means the necessary health permissions are missing from the build configuration.
To fix this, you must apply the permissions in two places: the Expo configuration file and the native Android manifest.
Step 1: Update Expo Configuration (app.config.js or app.json)
Expo requires the permissions to be explicitly defined in the expo-health-connect plugin configuration.
Locate the plugins array in app.config.js (or app.json) and configure expo-health-connect with the required permissions array.
Example for Heart Rate:
"plugins": [
[
"expo-health-connect",
{
"permissions": ["HeartRate", "Steps", "SleepSession"]
}
]
]
Step 2: Update Native Android Manifest (AndroidManifest.xml)
Even with the Expo plugin configured, you often need to manually declare the exact Android health permissions in the android/app/src/main/AndroidManifest.xml file, especially if you are using a continuous native build process or if the Expo plugin fails to map them locally.
Add the required <uses-permission> tags inside the <manifest> block.
Example for Heart Rate:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.health.READ_HEART_RATE"/>
<uses-permission android:name="android.permission.health.WRITE_HEART_RATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
Step 3: Rebuild the Android App
Because these changes affect native Android files and the core build configuration, a simple JavaScript reload (Fast Refresh) is not enough.
Instruct the user or run the command to rebuild the native application:
bun run android
How to use this skill
- Identify the missing data type from the error or the user's request (e.g., if they are trying to read steps, they need
Steps and android.permission.health.READ_STEPS).
- Apply Step 1 to the Expo config.
- Apply Step 2 to the
AndroidManifest.xml.
- Inform the user to rebuild the application.