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

Example project crashes when requesting permission #24

Open
ciriousjoker opened this issue Mar 30, 2024 · 8 comments
Open

Example project crashes when requesting permission #24

ciriousjoker opened this issue Mar 30, 2024 · 8 comments

Comments

@ciriousjoker
Copy link

Steps to reproduce:

  • Run the provided example project on an emulator (pixel 7 pro api level 34 in my case)
  • Click on "Request permission"

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
Copy link

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

@ciriousjoker
Copy link
Author

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
Copy link

me too.. did anyone solve it?

@quentinleguennec
Copy link

quentinleguennec commented Jul 24, 2024

@JongHyun9999 I figured out what caused the crash and a fix for it, you can see it here: quentinleguennec@da03ad8

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: cph-cachet/flutter-plugins#800 (comment)

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

@quentinleguennec
Copy link

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
Copy link

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
Copy link
Author

I'm not using this package anymore.

@quentinleguennec
Copy link

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

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

No branches or pull requests

5 participants