imdzx / flutter_health_connect

MIT License
3 stars 27 forks source link

Example project crashes when requesting permission #24

Open ciriousjoker opened 7 months ago

ciriousjoker commented 7 months ago

Steps to reproduce:

Expected: Health Connect should open

Actual: App crashes

E/AndroidRuntime(28951): FATAL EXCEPTION: main E/AndroidRuntime(28951): Process: dev.duynp.flutter_health_connect_example, PID: 28951 E/AndroidRuntime(28951): java.lang.IllegalStateException: Reply already submitted E/AndroidRuntime(28951): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:431) E/AndroidRuntime(28951): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:272) E/AndroidRuntime(28951): at dev.duynp.flutter_health_connect.FlutterHealthConnectPlugin$onActivityResult$2.invokeSuspend(FlutterHealthConnectPlugin.kt:340) E/AndroidRuntime(28951): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) E/AndroidRuntime(28951): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) E/AndroidRuntime(28951): at android.os.Handler.handleCallback(Handler.java:958) E/AndroidRuntime(28951): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(28951): at android.os.Looper.loopOnce(Looper.java:205) E/AndroidRuntime(28951): at android.os.Looper.loop(Looper.java:294) E/AndroidRuntime(28951): at android.app.ActivityThread.main(ActivityThread.java:8177) E/AndroidRuntime(28951): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(28951): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) E/AndroidRuntime(28951): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) E/AndroidRuntime(28951): Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@2288b73, Dispatchers.Main] I/Process (28951): Sending signal. PID: 28951 SIG: 9

MoritzMessner commented 7 months ago

i have the same problem... did you find a solution?

ciriousjoker commented 7 months ago

I think I was missing a permission.

Apparently for workouts you also need other implicit permissions. There's an issue in this repo somewhere about it

JongHyun9999 commented 6 months ago

me too.. did anyone solve it?

quentinleguennec commented 3 months ago

@JongHyun9999 I figured out what caused the crash and a fix for it, you can see it here: https://github.com/quentinleguennec/flutter_health_connect/commit/da03ad8c05157373244ae4d2ea56c7855c9ad829

BUT: This fix only fixes the crash, which allows to see what was causing the error to start with. This is due to Google changing things on their side (for the Privacy Policy), you can read more about it here: https://github.com/cph-cachet/flutter-plugins/issues/800#issuecomment-1807409934

Since this plugin is not being maintain I recommend trying this other plugin instead: https://pub.dev/packages/health

quentinleguennec commented 3 months ago

Ok, so I tried to move from this unmaintained plugin to the maintained health plugin but it just does not have enough for my need, so I started updating this plugin to support Android 14 and more.

This is still a work in progress, but feel free to look at the code here: https://github.com/quentinleguennec/flutter_health_connect/tree/feature_added_aggregate_function In particular I updated the Readme to show what's necessary to show the privacy policy on your side when a user taps the button in the permission activity, and I also updated the example app so you can test it.

carlos1219 commented 2 weeks ago

hi @quentinleguennec and @ciriousjoker did anyone find how to ask permission in background with workmanager? Because my app works perfect bu in background told me, that I need permissions and i dont kown why

ciriousjoker commented 2 weeks ago

I'm not using this package anymore.

quentinleguennec commented 2 weeks ago

@carlos1219 I'm not sure I understand the question, what are you trying to do and what does the error look like?