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

SDC : Proguard rules not available for apk shrink #1901

Closed
khyativyasargus opened this issue Mar 9, 2023 · 3 comments · Fixed by #1916
Closed

SDC : Proguard rules not available for apk shrink #1901

khyativyasargus opened this issue Mar 9, 2023 · 3 comments · Fixed by #1916
Assignees

Comments

@khyativyasargus
Copy link
Contributor

Describe the bug
While applying Proguard rules to shrink apk, app crashes.

Component
SDC library - demo reference app

To Reproduce
Steps to reproduce the behavior:

  1. Go to build.gradle.kts (:demo) file
  2. set debug build type config with "isMinifyEnabled" as true. Add or update following lines in buildTypes {}
    getByName("debug") {
    isMinifyEnabled = true
    proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
    }
    getByName("release") {
    isMinifyEnabled = false
    proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
    }
  3. sync and run app in device
  4. App crashes with an exception :
    java.util.MissingResourceException: Can't find bundle for base name h2.hapi-messages, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1561)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1384)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:771)
    at h2.a.e(:175)
    at h2.a.(:64)
    at h2.a.(:60)
    at e2.k.(:115)
    at e2.k.(:175)
    at e2.k.v(:1199)
    at e2.k.a(Unknown Source:0)
    at e2.j.apply(Unknown Source:2)
    at java.util.Map.computeIfAbsent(Map.java:1000)
    at java.util.Collections$SynchronizedMap.computeIfAbsent(Collections.java:2723)
    at e2.k.c(:1199)
    at n5.h$a.b(:71)
    at n5.g.d(:77)
    at n5.g.c(:52)
    at com.google.android.fhir.demo.FhirApplication.d(:67)
    at com.google.android.fhir.demo.FhirApplication.b(:32)
    at com.google.android.fhir.demo.FhirApplication$b.c(:34)
    at com.google.android.fhir.demo.FhirApplication$b.g(:34)

Expected behavior
Need required Proguard rules to avoid missing resource exception

Smartphone (please complete the following information):

  • Device: Pixel 4 emulator
  • Android version: 31

@jingtang10

@aditya-07 aditya-07 self-assigned this Mar 14, 2023
@aditya-07
Copy link
Collaborator

@khyativyasargus
The following rules need to be added to application's proguard-rules.pro file.

# hapi libs
-keep class ca.uhn.fhir.** { *; }
-keep class org.hl7.fhir.r4.hapi.ctx.*  { *; }
-keep class org.hl7.fhir.r4.**  { *; }
-keep class org.hl7.fhir.utilities.**  { *; }
-keep class org.hl7.fhir.exceptions.*  { *; }
-keep class org.hl7.fhir.instance.model.api.*  { *; }

# Used by HapiWorkerContext (fhirpath engine in QuestionnaireViewModel)
-keep class com.github.benmanes.caffeine.cache.**  { *; }

# sqlcipher
-keep class net.sqlcipher.** { *; }
#-keep class net.sqlcipher.database.** { *; }

# retrofit (https://github.com/square/retrofit/issues/3539)
-keep class com.google.android.fhir.sync.remote.RemoteFhirService { *; }

@khyativyasargus
Copy link
Contributor Author

Thank you @aditya-07 for your help ! Its working perfectly fine now!

@jingtang10
Copy link
Collaborator

@khyativyasargus can you please also review Aditya's PR #1916 and leave any comments you may have? Thanks!

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

Successfully merging a pull request may close this issue.

3 participants