react-native-health-connect: error: method setPermissionDelegate in class HealthConnectPermissionDelegate cannot be applied to given types
This is the error am getting
android/app/src/main/java/com/ziva/MainActivity.java:26: error: method setPermissionDelegate in class HealthConnectPermissionDelegate cannot be applied to given types;
HealthConnectPermissionDelegate.setPermissionDelegate(this);
^
required: ReactActivity,String
found: MainActivity
reason: actual and formal argument lists differ in length
1 error
FAILURE: Build completed with 2 failures.
as per installation guide I have made change on my MainActivity.java as my project is on java
on import part I added
import dev.matinzd.healthconnect.permissions.HealthConnectPermissionDelegate;
and replaced onCreate() method with this
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HealthConnectPermissionDelegate.setPermissionDelegate(this);
}
and also on my android studio I can see an error on same thing
Non-static method 'setPermissionDelegate(error.NonExistentClass, java.lang.String)' cannot be referenced from a static context
Environment:
- “react-native-health-connect”: “2.0.1”,
- “react-native”: “0.69.5”
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Comments: 22 (5 by maintainers)
In Java I call the setPermissionDelegate method like this:
HealthConnectPermissionDelegate.INSTANCE.setPermissionDelegate(this, "package.name");On Android 14 it works fine but for others it crushes
However, the app functions correctly on Android version 14 . When requesting permission using the Health Connect permission API , the permission modal appears as expected. However, upon requesting permission on lower Android versions, the API returns an empty error response. This occurs even after downloading the Health Connect app.
Manifest file :
Main Activity file :
Permission Rational file :
Package.json file :
Android 14 Execution and response :

Android 13 Execution and response :

@matinzd My application has the following setup:
react-native: 0.71.18 react-native-health-connect: ^2.0.1 buildToolsVersion: 34.0.0 minSdkVersion: 26 compileSdkVersion: 34 targetSdkVersion: 34 kotlinVersion: 1.8.0 The app works fine on Android 14, but it’s not functioning on versions lower than 14, such as Android 12 or 11. Specifically, the requestPermission() method isn’t being called on those lower versions.
Working in 14 version and for other version crash.
The method does not work. It does not prompt for permission on version 13, but it works fine on version 14.
version: react-native-health-connect@2.0.1
import { requestPermission } from ‘react-native-health-connect’; const grantedPermissions = await requestPermission([ ‘ActiveCaloriesBurned’, ‘BasalBodyTemperature’, ‘BasalMetabolicRate’, ]);