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 11.1.1] App crash on Health().hasPermissions([HealthDataType.STEPS]) #1098

Open
maybemuf opened this issue Dec 17, 2024 · 8 comments
Labels
bugfix a bug fix

Comments

@maybemuf
Copy link

maybemuf commented Dec 17, 2024

Plugin Name

health

Plugin Version

1.11.1

Device

Pixel 8 PRO API 33, Samsung Galaxy S10+

Operating System

Android 13, Android 9

Describe the bug

App crashes on devices with android version of 13 and bellow while attempting to read permision status via Health().hasPermissions([HealthDataType.STEPS]).

Steps to Reproduce

Unfortunatelly it doesnt reporuce on example app. But in my scenario i run final sdkStatus = await Health().getHealthConnectSdkStatus(); after if sdkStatus == HealthConnectSdkStatus.sdkAvailable i run Health().hasPermissions([HealthDataType.STEPS]) which leads to crash.

Expected Behavior

Not to crash

Actual Behavior

Crash. Tried wrapping this in try-catch block but it fatals anyway

Flutter Logs

E/AndroidRuntime(23502): FATAL EXCEPTION: main
E/AndroidRuntime(23502): Process: com.brightbird.app.dev, PID: 23502
E/AndroidRuntime(23502): android.os.RemoteException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1
E/AndroidRuntime(23502): 	at androidx.health.connect.client.impl.HealthConnectClientImpl.getGrantedPermissions(HealthConnectClientImpl.kt:308)
E/AndroidRuntime(23502): 	at androidx.health.connect.client.impl.HealthConnectClientImpl$getGrantedPermissions$1.invokeSuspend(Unknown Source:14)
E/AndroidRuntime(23502): 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime(23502): 	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime(23502): 	at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(23502): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(23502): 	at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(23502): 	at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(23502): 	at android.app.ActivityThread.main(ActivityThread.java:7872)
E/AndroidRuntime(23502): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23502): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime(23502): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/AndroidRuntime(23502): 	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@cf49fe1, Dispatchers.Main]
E/AndroidRuntime(23502): Caused by: android.os.RemoteException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1
E/AndroidRuntime(23502): 	at androidx.health.platform.client.impl.error.ErrorStatusConverterKt.toException(ErrorStatusConverter.kt:49)
E/AndroidRuntime(23502): 	at androidx.health.platform.client.impl.FilterGrantedPermissionsCallback.onError(FilterGrantedPermissionsCallback.kt:34)
E/AndroidRuntime(23502): 	at androidx.health.platform.client.service.IFilterGrantedPermissionsCallback$Stub.onTransact(IFilterGrantedPermissionsCallback.java:72)
E/AndroidRuntime(23502): 	at android.os.Binder.execTransactInternal(Binder.java:1285)
E/AndroidRuntime(23502): 	at android.os.Binder.execTransact(Binder.java:1244)
I/Process (23502): Sending signal. PID: 23502 SIG: 9

Screenshots

No response

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1.1 24B91 darwin-arm64, locale en-UA)
    • Flutter version 3.24.5 on channel stable at /Users/lesha/fvm/versions/default
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (5 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

Additional Information

No response

@maybemuf maybemuf added the bugfix a bug fix label Dec 17, 2024
@yogeshButani
Copy link

If delete google fit, it is not giving steps count even health connect is already installed.
Some users reported that they have installed health connect and google fit, then it works perfectly fine, but when delete google fit app, then it stops to give steps count data don't know why.
It means that data was getting from google fit, when uninstalled it, it stops giving data.
What I found is that, I think health connect not gives data till i allow manually my app can access data by going into google fit app.

Can someone tell why this is hapenning.?

@tajjacob
Copy link

If delete google fit, it is not giving steps count even health connect is already installed. Some users reported that they have installed health connect and google fit, then it works perfectly fine, but when delete google fit app, then it stops to give steps count data don't know why. It means that data was getting from google fit, when uninstalled it, it stops giving data. What I found is that, I think health connect not gives data till i allow manually my app can access data by going into google fit app.

Can someone tell why this is hapenning.?
image

From my understanding, as mention in the website, Health connect is a central dashboard. you need health connect to acces data from google fit.

@yogeshButani
Copy link

@tajjacob
Thank you for replying, still I have some doubt about this, please respond again if you have answer of below query.
so basically we need both aps to be installed on android health connect and googlefit? to read the steps data?

@tajjacob
Copy link

@yogeshButani yes.

@yogeshButani
Copy link

@tajjacob
but why health package of flutter not telling us about that?
they have mentioned in their doc that

NOTE: Google has deprecated the Google Fit API. According to the documentation, as of May 1st 2024 developers cannot sign up for using the API. As such, this package has removed support for Google Fit as of version 11.0.0 and users are urged to upgrade as soon as possible.

@tajjacob
Copy link

@yogeshButani google fit is still there but we cannot access it.

@iarata
Copy link
Contributor

iarata commented Jan 3, 2025

@yogeshButani If the logs are from the health app example try to reduce the number of permissions being asked by the app. Also bear in mind that from Health 11, the package does not support Google Fit anymore and if the issues are related to Google Fit, you should update your application.

@iarata iarata changed the title [HEALTH 11.1.1] App crash on Health().hasPermissions([HealthDataType.STEPS]) [Health 11.1.1] App crash on Health().hasPermissions([HealthDataType.STEPS]) Jan 3, 2025
@iarata
Copy link
Contributor

iarata commented Jan 3, 2025

In the example app I just made a extra button to check the permissions on Android 13 and everything was working fine, even if the permission was not given.

Future<void> checkStepPermissions() async {
    bool? hasPermissions = await Health().hasPermissions([HealthDataType.STEPS]);
    debugPrint('Has permissions to read steps: $hasPermissions');
  }

Perhaps it is how you're implementing the package that causes the issue?

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

No branches or pull requests

4 participants