-
-
Notifications
You must be signed in to change notification settings - Fork 83
Description
I installed the library using:
npm install react-native-health-connect
Then I added the required configuration in my MainActivity:
import dev.matinzd.healthconnect.permissions.HealthConnectPermissionDelegate
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // In order to handle permission contract results, we need to set the permission delegate. HealthConnectPermissionDelegate.setPermissionDelegate(this) }
But when I built the app, I got the following errors:
e: file:///Users/cpqd2/Desktop/Projetos/mrc-mobile/android/app/src/main/java/com/mrc_mobile/MainActivity.kt:8:8 Unresolved reference 'dev'. e: file:///Users/cpqd2/Desktop/Projetos/mrc-mobile/android/app/src/main/java/com/mrc_mobile/MainActivity.kt:21:9 Unresolved reference 'HealthConnectPermissionDelegate'.
So I tried to manually link the library. I added:
android/settings.gradle
include ':react-native-health-connect' project(':react-native-health-connect').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-health-connect/android')
android/app/build.gradle
implementation project(':react-native-health-connect')
android/app/src/main/java/.../MainApplication.java
add(HealthConnectPackage())
After this manual linking, the build errors were resolved and the project compiled successfully.
However, when I call any method from the React Native layer, I get this runtime error:
Error: Uncaught (in promise, id: 0): "Error: The package 'react-native-health-connect' doesn't seem to be linked. Make sure: - You rebuilt the app after installing the package - You are not using Expo Go " Caused by: Error: The package 'react-native-health-connect' doesn't seem to be linked. Make sure: - You rebuilt the app after installing the package - You are not using Expo Go at ?anon_0_ (WearableView.tsx:15:43) at next (native) at readSampleData (WearableView.tsx:13:23) at anonymous (WearableView.tsx:36:19) ... skipping 161 frames
Environment
React Native: 0.82.0
react-native-health-connect: ^3.5.0
Android - Using default RN 0.82 architecture
Summary
Even after manual linking fixes the Android build errors, React Native still cannot find the module at runtime.
Additional Notes
The issue occurs on a clean rebuild (cd android && ./gradlew clean).
Tried reinstalling node_modules and clearing Gradle cache with no success.
Other native modules work normally.