Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HEALTH 8.1.0] - Null pointer exception in hasPermissionsHC method #878

Closed
bardram opened this issue Jan 11, 2024 · 1 comment · Fixed by #884
Closed

[HEALTH 8.1.0] - Null pointer exception in hasPermissionsHC method #878

bardram opened this issue Jan 11, 2024 · 1 comment · Fixed by #884
Assignees
Labels
bugfix a bug fix improvement an improvement

Comments

@bardram
Copy link
Contributor

bardram commented Jan 11, 2024

Device and OS

  • Device: Samsung S10e
  • OS: Android 12

When calling the hasPermissions method, there is a PlatformException in Flutter wich comes from a NullPointerException in Kotlin:

E/flutter (29560): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, null, null, java.lang.NullPointerException
E/flutter (29560): 	at cachet.plugins.health.HealthPlugin.hasPermissionsHC(HealthPlugin.kt:1598)

Trying to collect these health data types:

    // Define which health types to collect.
    var healthDataTypes = [
      HealthDataType.DISTANCE_WALKING_RUNNING,
      HealthDataType.EXERCISE_TIME,
      HealthDataType.STEPS,
      HealthDataType.BASAL_ENERGY_BURNED,
      HealthDataType.WEIGHT,
      HealthDataType.SLEEP_SESSION,
    ];
@bardram bardram added the bugfix a bug fix label Jan 11, 2024
@bardram
Copy link
Contributor Author

bardram commented Jan 15, 2024

I've now found why this happens. It's because I add

    HealthDataType.DISTANCE_WALKING_RUNNING,
    HealthDataType.EXERCISE_TIME,

to the list - but these two data types are not supported on Health Connect. So - when removing them, it works.

However - it might be useful with more telling error messages than a null pointer exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix a bug fix improvement an improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants