hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.04k stars 1.33k forks source link

[support android build] testCoverageEnabled true occurs build error on debug #5210

Open kjlee5435 opened 1 year ago

kjlee5435 commented 1 year ago

Describe the bug build error

To Reproduce Steps to reproduce the behavior:

  1. add testCoverageEnabled true to debug buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { testCoverageEnabled true } }
  2. try to make debug occurs follow error

    Could not resolve all files for configuration ':App:devDebugRuntimeClasspath'. Failed to transform org.hl7.fhir.r4-6.0.1.jar (ca.uhn.hapi.fhir:org.hl7.fhir.r4:6.0.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=true, dexing-is-debuggable=true, dexing-min-sdk=26, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}. Execution failed for JacocoTransform: /home-mc/kwangjo.lee/.gradle/caches/modules-2/files-2.1/ca.uhn.hapi.fhir/org.hl7.fhir.r4/6.0.1/40c341859f1142a7dc7ed5a9da775cd6fe8b12d6/org.hl7.fhir.r4-6.0.1.jar. org.gradle.internal.operations.BuildOperationInvocationException (no error message)

Expected behavior no error

Environment (please complete the following information): implementation ('ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.6.0') implementation ("ca.uhn.hapi.fhir:hapi-fhir-android:6.6.0")

kjlee5435 commented 1 year ago

seems root cause : 2023-08-18T13:40:00.825+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.io.IOException: Error while instrumenting org/hl7/fhir/r4/formats/JsonParser.class with JaCoCo 0.8.8.202204050719/5dcf34a. 2023-08-18T13:40:00.825+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jacoco.core.instr.Instrumenter.instrumentError(Instrumenter.java:161) 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:111) 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:136) 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 121 more 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.objectweb.asm.ClassTooLargeException: Class too large: org/hl7/fhir/r4/formats/JsonParser 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.objectweb.asm.ClassWriter.toByteArray(ClassWriter.java:599) 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:92) 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.jacoco.core.instr.Instrumenter.instrument(Instrumenter.java:109) 2023-08-18T13:40:00.826+0900 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] ... 122 more

kjlee5435 commented 1 year ago

Also, for android project build, we need proper proguard guide.

For 6.6.0 we need to add

HAPI

-dontwarn com.ctc.wstx.stax.WstxInputFactory -dontwarn com.ctc.wstx.stax.WstxOutputFactory

I think some more keep rules are need for this proejct..

kjlee5435 commented 1 year ago

Recent 6.8.0 are not build on android due to guava and 6.6.2 also not build due to fastxml.

jingtang10 commented 3 months ago

@aditya-07