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

Added rules for required for engine and datacapture libraries. #1916

Merged
merged 10 commits into from
Jun 13, 2024

Conversation

aditya-07
Copy link
Collaborator

@aditya-07 aditya-07 commented Mar 17, 2023

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #1901 #2327

Description
Added the proguard rules required for engine and datacapture libs in Demo and catalog app respectively.
Added rules to respective proguard-rules.pro files for engine and datacapture library as per Android's considerations.
This way, R8 automatically applies the provided rules and developers don't have to include the rules explicitly in the app's proguard-rules file ( see Library dependencies ).

Alternative(s) considered
Publish the rules in wiki, but then users will have to check it with every release to check if rules have been modified.

Type
Choose one: Bug fix

Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

Copy link
Contributor

@omarismail94 omarismail94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change @aditya-07 ! Just two nits

catalog/proguard-rules.pro Outdated Show resolved Hide resolved
engine/proguard-rules.pro Outdated Show resolved Hide resolved
@omarismail94
Copy link
Contributor

Im also assuming we don't need this in any of our other libraries as they depend on engine and datacapture

catalog/proguard-rules.pro Show resolved Hide resolved
catalog/proguard-rules.pro Outdated Show resolved Hide resolved
datacapture/proguard-rules.pro Outdated Show resolved Hide resolved
datacapture/proguard-rules.pro Outdated Show resolved Hide resolved
datacapture/proguard-rules.pro Outdated Show resolved Hide resolved
@jingtang10
Copy link
Collaborator

can you also minify the datacapture and the demo app and add a build test?

@jingtang10
Copy link
Collaborator

revisiting this - discussed with aditya - let's try to merge this to enable minification and code shrinking.

some relevant links: https://developer.android.com/build/shrink-code#keep-code, https://developer.android.com/studio/projects/android-library

it's not idea if developers have to copy and paste these rules in their own apps.

@aditya-07 aditya-07 marked this pull request as ready for review June 12, 2024 12:46
@aditya-07 aditya-07 requested a review from MJ1998 as a code owner June 12, 2024 12:46
Copy link
Collaborator

@jingtang10 jingtang10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this change can you turn on minification for the demo apps?

catalog/proguard-rules.pro Outdated Show resolved Hide resolved
datacapture/proguard-rules.pro Show resolved Hide resolved
@jingtang10
Copy link
Collaborator

jingtang10 commented Jun 13, 2024

tested a minified release build of the demo app and got this when i create a patient:

2024-06-13 17:22:21.350 27518-27518 AndroidRuntime          com.google.android.fhir.demo         E  FATAL EXCEPTION: main
                                                                                                    Process: com.google.android.fhir.demo, PID: 27518
                                                                                                    ca.uhn.fhir.context.ConfigurationException: HAPI-1753: Unable to initialize StAX - XML processing is disabled
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.newInputFactory(SourceFile:59)
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.getOrCreateInputFactory(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.createXmlReader(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.parser.XmlParser.createStreamReader(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.parser.XmlParser.doParseResource(Unknown Source:0)
                                                                                                    	at ca.uhn.fhir.parser.BaseParser.parseResource(SourceFile:4)
                                                                                                    	at ca.uhn.fhir.parser.BaseParser.parseResource(SourceFile:2)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.parseBundle(Unknown Source:8)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.loadStructureDefinitions(SourceFile:80)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.provideStructureDefinitionMap(Unknown Source:30)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.fetchStructureDefinition(SourceFile:62)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupport.fetchStructureDefinition(Unknown Source:2)
                                                                                                    	at ca.uhn.fhir.context.support.IValidationSupport.fetchResource(Unknown Source:136)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain.fetchResource(Unknown Source:18)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.lambda$fetchResource$0(Unknown Source:2)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.b(SourceFile:1)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.support.f.apply(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.CacheDelegator.lambda$get$0(Unknown Source:0)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.CacheDelegator.a(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.a.call(SourceFile:1)
                                                                                                    	at a8.j0.load(SourceFile:1)
                                                                                                    	at a8.h0.h(SourceFile:28)
                                                                                                    	at a8.m0.l(SourceFile:185)
                                                                                                    	at a8.b1.e(SourceFile:74)
                                                                                                    	at h4.t.b(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.CacheDelegator.get(SourceFile:10)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.fetchResource(Unknown Source:15)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.fetchResourceWithException(SourceFile:1)
                                                                                                    	at i6.a.fetchResourceWithException(SourceFile:1)
                                                                                                    	at org.hl7.fhir.r4.context.BaseWorkerContext.fetchResource(Unknown Source:0)
                                                                                                    	at org.hl7.fhir.r4.context.SimpleWorkerContext.fetchResource(SourceFile:1)
                                                                                                    	at org.hl7.fhir.r4.context.BaseWorkerContext.fetchTypeDefinition(Unknown Source:8)
                                                                                                    	at org.hl7.fhir.r4.utils.FHIRPathEngine.execute(SourceFile:2)
                                                                                                    	at org.hl7.fhir.r4.utils.FHIRPathEngine.execute(SourceFile:1)
                                                                                                    	at org.hl7.fhir.r4.utils.FHIRPathEngine.evaluate(SourceFile:4)
                                                                                                    	at i6.d.a(SourceFile:7)
                                                                                                    	at b6.d0.g(SourceFile:220)
                                                                                                    	at a6.i.r(SourceFile:134)
                                                                                                    	at a6.i.h(SourceFile:16)
                                                                                                    	at m1.c0.r(SourceFile:68)
                                                                                                    	at m1.c0.m(SourceFile:13)
                                                                                                    	at s3.u0.A0(SourceFile:5)
                                                                                                    	at g8.b.u1(SourceFile:75)
                                                                                                    	at m1.b0.r(SourceFile:88)
                                                                                                    	at l9.a.f(SourceFile:1)
                                                                                                    	at aa.b0.run(SourceFile:1)
                                                                                                    	at aa.i0.P(SourceFile:159)
                                                                                                    	at g8.b.c1(SourceFile:99)
                                                                                                    	at g.g.run(SourceFile:169)
                                                                                                    	at d.p0.run(SourceFile:179)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    	Suppressed: fa.f: [i1{Cancelling}@2d8872b, Dispatchers.Main.immediate]
                                                                                                    Caused by: z8.a: Provider com.ctc.wstx.stax.WstxInputFactory not found
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.newInputFactory(SourceFile:41)
                                                                                                    	... 52 more

@aditya-07
Copy link
Collaborator Author

tested a minified release build of the demo app and got this when i create a patient:

2024-06-13 17:22:21.350 27518-27518 AndroidRuntime          com.google.android.fhir.demo         E  FATAL EXCEPTION: main
                                                                                                    Process: com.google.android.fhir.demo, PID: 27518
                                                                                                    ca.uhn.fhir.context.ConfigurationException: HAPI-1753: Unable to initialize StAX - XML processing is disabled
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.newInputFactory(SourceFile:59)
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.getOrCreateInputFactory(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.createXmlReader(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.parser.XmlParser.createStreamReader(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.parser.XmlParser.doParseResource(Unknown Source:0)
                                                                                                    	at ca.uhn.fhir.parser.BaseParser.parseResource(SourceFile:4)
                                                                                                    	at ca.uhn.fhir.parser.BaseParser.parseResource(SourceFile:2)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.parseBundle(Unknown Source:8)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.loadStructureDefinitions(SourceFile:80)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.provideStructureDefinitionMap(Unknown Source:30)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupportBundleStrategy.fetchStructureDefinition(SourceFile:62)
                                                                                                    	at ca.uhn.fhir.context.support.DefaultProfileValidationSupport.fetchStructureDefinition(Unknown Source:2)
                                                                                                    	at ca.uhn.fhir.context.support.IValidationSupport.fetchResource(Unknown Source:136)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain.fetchResource(Unknown Source:18)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.lambda$fetchResource$0(Unknown Source:2)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.b(SourceFile:1)
                                                                                                    	at org.hl7.fhir.common.hapi.validation.support.f.apply(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.CacheDelegator.lambda$get$0(Unknown Source:0)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.CacheDelegator.a(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.a.call(SourceFile:1)
                                                                                                    	at a8.j0.load(SourceFile:1)
                                                                                                    	at a8.h0.h(SourceFile:28)
                                                                                                    	at a8.m0.l(SourceFile:185)
                                                                                                    	at a8.b1.e(SourceFile:74)
                                                                                                    	at h4.t.b(SourceFile:1)
                                                                                                    	at ca.uhn.fhir.sl.cache.guava.CacheDelegator.get(SourceFile:10)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.fetchResource(Unknown Source:15)
                                                                                                    	at org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext.fetchResourceWithException(SourceFile:1)
                                                                                                    	at i6.a.fetchResourceWithException(SourceFile:1)
                                                                                                    	at org.hl7.fhir.r4.context.BaseWorkerContext.fetchResource(Unknown Source:0)
                                                                                                    	at org.hl7.fhir.r4.context.SimpleWorkerContext.fetchResource(SourceFile:1)
                                                                                                    	at org.hl7.fhir.r4.context.BaseWorkerContext.fetchTypeDefinition(Unknown Source:8)
                                                                                                    	at org.hl7.fhir.r4.utils.FHIRPathEngine.execute(SourceFile:2)
                                                                                                    	at org.hl7.fhir.r4.utils.FHIRPathEngine.execute(SourceFile:1)
                                                                                                    	at org.hl7.fhir.r4.utils.FHIRPathEngine.evaluate(SourceFile:4)
                                                                                                    	at i6.d.a(SourceFile:7)
                                                                                                    	at b6.d0.g(SourceFile:220)
                                                                                                    	at a6.i.r(SourceFile:134)
                                                                                                    	at a6.i.h(SourceFile:16)
                                                                                                    	at m1.c0.r(SourceFile:68)
                                                                                                    	at m1.c0.m(SourceFile:13)
                                                                                                    	at s3.u0.A0(SourceFile:5)
                                                                                                    	at g8.b.u1(SourceFile:75)
                                                                                                    	at m1.b0.r(SourceFile:88)
                                                                                                    	at l9.a.f(SourceFile:1)
                                                                                                    	at aa.b0.run(SourceFile:1)
                                                                                                    	at aa.i0.P(SourceFile:159)
                                                                                                    	at g8.b.c1(SourceFile:99)
                                                                                                    	at g.g.run(SourceFile:169)
                                                                                                    	at d.p0.run(SourceFile:179)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    	Suppressed: fa.f: [i1{Cancelling}@2d8872b, Dispatchers.Main.immediate]
                                                                                                    Caused by: z8.a: Provider com.ctc.wstx.stax.WstxInputFactory not found
                                                                                                    	at ca.uhn.fhir.util.XmlUtil.newInputFactory(SourceFile:41)
                                                                                                    	... 52 more

Its fixed now with new rules update.

@aditya-07 aditya-07 enabled auto-merge (squash) June 13, 2024 19:15
@aditya-07 aditya-07 merged commit 70fd2ae into google:master Jun 13, 2024
4 checks passed
@jingtang10
Copy link
Collaborator

Thanks Aditya!

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

Successfully merging this pull request may close these issues.

SDC : Proguard rules not available for apk shrink
3 participants