HealthConnect – Permission Dialog not working in release mode

Issue

App crashes when the app is running in release mode with proguard enabled.

Here is the Crash report.

Fatal Exception: java.lang.IllegalArgumentException: Unknown data type name h0
   at android.os.Parcel.createExceptionOrNull(Parcel.java:2429)
   at android.os.Parcel.createException(Parcel.java:2409)
   at android.os.Parcel.readException(Parcel.java:2392)
   at android.os.Parcel.readException(Parcel.java:2334)
   at androidx.health.platform.client.service.IHealthDataService$Stub$Proxy.getGrantedPermissions(IHealthDataService.java:414)
   at androidx.health.platform.client.impl.ServiceBackedHealthDataClient.getGrantedPermissions$lambda-1(ServiceBackedHealthDataClient.kt:93)
   at androidx.health.platform.client.impl.ServiceBackedHealthDataClient.$r8$lambda$hhWerw-hyBNCC_kPGtX4mZNDQdM(ServiceBackedHealthDataClient.kt)
   at androidx.health.platform.client.impl.ServiceBackedHealthDataClient$$InternalSyntheticLambda$0$605e77fbbfc877805d8dd88d131a334eb9370ed10712fd7118bc908c2d0b7ca2$0.execute(ServiceBackedHealthDataClient.java:6)
   at androidx.health.platform.client.impl.ipc.Client$3.execute(Client.java:279)
   at androidx.health.platform.client.impl.ipc.internal.ServiceConnection.execute(ServiceConnection.java:243)
   at androidx.health.platform.client.impl.ipc.internal.ServiceConnection.enqueue(ServiceConnection.java:200)
   at androidx.health.platform.client.impl.ipc.internal.ConnectionManager.handleMessage(ConnectionManager.java:123)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loopOnce(Looper.java:201)
   at android.os.Looper.loop(Looper.java:288)
   at android.os.HandlerThread.run(HandlerThread.java:67)

Any Proguard rules should I need to add for health Connect API?

Solution

Aug. 3, 2022:

As of version 1.0.0-alpha03, this has been fixed on the library’s end.

Links :


For the meantime time, you can add these rules into your proguard file:

-keep public class androidx.health.** {
  public protected private *;
}
-dontwarn androidx.health.**

It is quite overarching to ignore the entire lib at the moment, but at least it gets your project to build under release.

Answered By – Paul John Parreno

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published