1

I am trying to add following dependencies into my android studio project, but it seems something goes wrong which I don't understand!

compile 'ca.uhn.hapi.fhir:hapi-fhir-base:1.4'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2:1.4'
compile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:1.4'
compile 'org.slf4j:slf4j-simple:1.6.1'

and this is the error:

    Information:Gradle tasks [:app:assembleDebug]
Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for lintOptions as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage it with jarjar to change the class packages
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preLintOptionsBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportPercent2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComJjoe64Graphview401Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac
Note: /PolimiMac/PersonalHealthRecord/app/src/main/java/polimi/aap/yas/personalhealthrecord/Chronograms.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:transformClassesWithJarMergingForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/json/Json.class
Information:BUILD FAILED
Information:Total time: 27.738 secs
Information:1 error
Information:3 warnings
Information:See complete output in console

in fact , before adding those dependencies everything worked fine without error. do you know what is the problem?! Thank you in advance for your helps!

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Jasmine
  • 222
  • 2
  • 12
  • Do you have proguard turned on? – Aritra Roy Jun 12 '16 at 16:01
  • This might not be helpful but maybe try cleaning project and rebuilding? – aquaflamingo Jun 12 '16 at 16:06
  • @AritraRoy how can I turned it on? – Jasmine Jun 12 '16 at 16:07
  • @RobertSimoes I did clean the project , but it doesn't work! – Jasmine Jun 12 '16 at 16:08
  • Go to your build.gradle and check your "minifyEnabled" value? Is it true or false? I need this information to solve your problem. – Aritra Roy Jun 12 '16 at 16:09
  • @AritraRoy it's "false" – Jasmine Jun 12 '16 at 16:11
  • You need to exclude both javax.json and org.apache.httpcomponents from your dependencies – OneCricketeer Jun 12 '16 at 16:17
  • 1
    Why aren't you using the Android dependency? http://mvnrepository.com/artifact/ca.uhn.hapi.fhir/hapi-fhir-android – OneCricketeer Jun 12 '16 at 16:21
  • @cricket_007 sorry but how should I exclude those ones? – Jasmine Jun 12 '16 at 16:27
  • I'm not sure exactly how you should write it, but first check that last link, otherwise look at "Exclude Transitive Dependency by Dependency" here http://www.concretepage.com/build-tools/gradle/gradle-exclude-transitive-dependency-example – OneCricketeer Jun 12 '16 at 16:33
  • @cricket_007 I tried that link , using gradle tab, and copied them, but still I face the error. Noe let me check the exclude solution. – Jasmine Jun 12 '16 at 16:38
  • @Jasmine try this dependencies { compile 'ca.uhn.hapi.fhir:hapi-fhir-base:1.5' compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-hl7org-dstu2:1.5' compile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:1.5' compile 'org.slf4j:slf4j-simple:1.7.21' } – Muhammad Waleed Jun 12 '16 at 20:14
  • clean and rebuild your project... – Muhammad Waleed Jun 12 '16 at 20:15
  • @WaqarYounis I faced the error again! – Jasmine Jun 13 '16 at 12:53
  • @cricket_007 I excluded those dependencies you've told, but I faced another error! Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1 – Jasmine Jun 14 '16 at 11:57
  • That error literally tells me nothing other than gradle has not successfully built your project. The actual reason for that exception is located in the full gradle output – OneCricketeer Jun 14 '16 at 15:25
  • And I didn't tell you which dependencies to exclude. I only sent you a link of how to write an exclude statement in Gradle. The library that you need to exclude is `javax.json.*` – OneCricketeer Jun 14 '16 at 15:27

1 Answers1

1

Finally I could solve the problem. cleaning and rebuilding project were not the solutions! I didn't add dependencies through writing codes in Gradle. in fact I downloaded Jar libraries from the following link: http://mvnrepository.com/artifact/ca.uhn.hapi.fhir/hapi-fhir-android/1.5

I downloaded three libraries which I needed:

hapi-fhir-structures-dstu2-1.5.jar , hapi-fhir-base-1.5.jar , hapi-fhir-android-1.5.jar

then I moved them to "lib" folder of the app -> sync the gradle

Jasmine
  • 222
  • 2
  • 12