android / android/android-health-connect-codelab
Problem with ExerciseSessionRecord constructor
- Dominant language
- Kotlin
- Stars
- 63
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
I'm struggling to understand how I can create an ExerciseSessionRecord to store in Health Connect when the constructor is declared internal (restricted to library).
```
class ExerciseSessionRecord
@RestrictTo(RestrictTo.Scope.LIBRARY)
internal constructor(...
```
I try with stable version of the library 1.1.0, with 1.1.0-alpha12 (since the guide refers to this specific version), and with 1.2.0-alpha02 but I am not able to find any way for creating ExerciseSessionRecord object.
The strangest thing is that all the documentation and examples refer to this method as 'public' but looking at the source code it does not.
[health-connect write-data](https://developer.android.com/health-and-fitness/health-connect/write-data)
The compile error from Android Studio is:
ExerciseSessionRecord can only be called from within the same library (androidx.health.connect:connect-client)
How I can create an ExerciseSessionRecord to store in Health Connect?
For some reason, the constructor only works when called from Java rather than Kotlin.
[https://stackoverflow.com/questions/79836701/unable-to-create-an-exercisesessionrecord-to-store-in-health-connect](https://stackoverflow.com/questions/79836701/unable-to-create-an-exercisesessionrecord-to-store-in-health-connect)
Contributor guide
Research direction
Start by reproducing the Kotlin compile error for the ExerciseSessionRecord constructor and compare its declaration with the linked Health Connect write-data documentation and Stack Overflow report. Done means the repository's guidance and the available construction path agree for the library versions named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100