Open chrisvidal opened 1 year ago
manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="sg.edu.nus.hopeprogram"
tools:replace="allowBackup"
android:allowBackup="false">
<!-- Check whether Health Connect is installed or not -->
<queries>
<package android:name="com.google.android.apps.healthdata" />
<intent>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
</intent>
</queries>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION"/>
<!-- Permissions for new android API (Health Connect) -->
<uses-permission android:name="android.permission.health.READ_STEPS"/>
this is the error log
/FLUTTER_HEALTH(15950): Access Granted (to Health Connect)!
E/AndroidRuntime(15950): FATAL EXCEPTION: main
E/AndroidRuntime(15950): Process: sg.edu.nus.hopeprogram, PID: 15950
E/AndroidRuntime(15950): java.lang.SecurityException: [android.permission.health.READ_STEPS] is not declared!
E/AndroidRuntime(15950): at androidx.health.platform.client.impl.error.ErrorStatusConverterKt.toException(ErrorStatusConverter.kt:47)
E/AndroidRuntime(15950): at androidx.health.platform.client.impl.ReadDataRangeCallback.onError(ReadDataRangeCallback.kt:35)
E/AndroidRuntime(15950): at androidx.health.platform.client.service.IReadDataRangeCallback$Stub.onTransact(IReadDataRangeCallback.java:75)
E/AndroidRuntime(15950): at android.os.Binder.execTransactInternal(Binder.java:1344)
E/AndroidRuntime(15950): at android.os.Binder.execTransact(Binder.java:1275)
E/AndroidRuntime(15950): Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@790571b, Dispatchers.Main]
I/Process (15950): Sending signal. PID: 15950 SIG: 9
Lost connection to device.
Did you follow all the steps laid out in this guide: https://developer.android.com/guide/health-and-fitness/health-connect/get-started? In addition, it is recommended to start out with the example AndroidManifest file, and then removing the permissions you don't need, while testing regularly. Some permissions depend on each other, even if it may not be obvious.
yes I followed and copied over the manifest.xml into my app. and it crashes every time i want to access health data, only the steps. is there any particular device or android simulator to make it work?
My guess is that you'll need to make a Health Connect API request.
The thing is that it works fine on my local simulator and my android phone. But not on my client's Android and Oppo phone even though they did all the necessary steps to install google fit and health connect apps. My app is properly asking for permission to read data through Health Connect, and after allowing, a message popups saying that "The app can not access Health Connect" and then crashes
The Health Connect API request is in progress for approval, let's see if that fix the issue on release mode.
After google approval, we managed to implement and run the Health Connect code on our app. However, it crashes randomly with the following crash log. Any idea?
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nus.hope/sg.edu.nus.hopeprogram.MainActivity}: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so"
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1808)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6669)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so"
at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete (FlutterLoader.java)
at io.flutter.embedding.engine.FlutterEngineGroup.<init> (FlutterEngineGroup.java)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine (FlutterActivityAndFragmentDelegate.java)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach (FlutterActivityAndFragmentDelegate.java)
at io.flutter.embedding.android.FlutterActivity.onCreate (FlutterActivity.java)
at android.app.Activity.performCreate (Activity.java:7136)
at android.app.Activity.performCreate (Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271)
at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate (MonitoringInstrumentation.java:2)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2893)
Caused by java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so"
at java.util.concurrent.FutureTask.report (FutureTask.java:123)
at java.util.concurrent.FutureTask.get (FutureTask.java:193)
at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete (FlutterLoader.java)
Caused by java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so"
at java.lang.Runtime.loadLibrary0 (Runtime.java:1012)
at java.lang.System.loadLibrary (System.java:1669)
at io.flutter.embedding.engine.FlutterJNI.loadLibrary (FlutterJNI.java)
at io.flutter.embedding.engine.loader.FlutterLoader$1.call (FlutterLoader.java)
at io.flutter.embedding.engine.loader.FlutterLoader$1.call (FlutterLoader.java)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:764)
After google approval, we managed to implement and run the Health Connect code on our app. However, it crashes randomly with the following crash log. Any idea?
Exception java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nus.hope/sg.edu.nus.hopeprogram.MainActivity}: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so" at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2913) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1808) at android.os.Handler.dispatchMessage (Handler.java:106) at android.os.Looper.loop (Looper.java:193) at android.app.ActivityThread.main (ActivityThread.java:6669) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858) Caused by java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so" at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete (FlutterLoader.java) at io.flutter.embedding.engine.FlutterEngineGroup.<init> (FlutterEngineGroup.java) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine (FlutterActivityAndFragmentDelegate.java) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach (FlutterActivityAndFragmentDelegate.java) at io.flutter.embedding.android.FlutterActivity.onCreate (FlutterActivity.java) at android.app.Activity.performCreate (Activity.java:7136) at android.app.Activity.performCreate (Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271) at androidx.test.runner.MonitoringInstrumentation.callActivityOnCreate (MonitoringInstrumentation.java:2) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2893) Caused by java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so" at java.util.concurrent.FutureTask.report (FutureTask.java:123) at java.util.concurrent.FutureTask.get (FutureTask.java:193) at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete (FlutterLoader.java) Caused by java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk", zip file "/data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/lib/x86, /data/app/androidx.test.tools.crawler-u6P2GfvGCt9pytuc_VK7gQ==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/base.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.en.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.x86.apk!/lib/x86, /data/app/com.nus.hope-uihiWoCgu6cRXuAHTHioHw==/split_config.xxhdpi.apk!/lib/x86, /system/lib]]] couldn't find "libflutter.so" at java.lang.Runtime.loadLibrary0 (Runtime.java:1012) at java.lang.System.loadLibrary (System.java:1669) at io.flutter.embedding.engine.FlutterJNI.loadLibrary (FlutterJNI.java) at io.flutter.embedding.engine.loader.FlutterLoader$1.call (FlutterLoader.java) at io.flutter.embedding.engine.loader.FlutterLoader$1.call (FlutterLoader.java) at java.util.concurrent.FutureTask.run (FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641) at java.lang.Thread.run (Thread.java:764)
Did you get a solution macha?
Is there any way to catch this errors like
java.lang.SecurityException: android.health.connect.HealthConnectException: java.lang.SecurityException: Caller doesn't have android.permission.health.READ_STEPSto read to record typeclass android.health.connect.datatypes.StepsRecord
and handle so that the app displays an error instead of crashing?
Remember to specify the plugin name in the title!
Device / Emulator and OS
Android Samsung A11 Pixel 4 Tiramisu
Describe the bug
Very confused on how to use Health Connect, everything that nede to be done outside the code itself
Did anyone manage to use HealthConnect and if yes, what is the whole process? How to make our app compatible with Health Connect? in developer mode not yet in the play store? and from the play store?