Pact-JVM fails with Android
See original GitHub issueWe are trying to setup Pact for a new project using iOS and Android consumers. We are facing issues with Android when running Pact-jvm because of the Scala requirement and on iOS we also need to support iOS 7 (for iPhone 4) which seems to be incompatible with the existing Swift implementation. Did you guys find any workaround for these issues?
Our project is using au.com.dius:pact-jvm-consumer_2.11:3.2.1
I’ve publised an empty Android Project with just Pact and gives the same error:
https://github.com/jcarlos/AndroidPact
This one includes:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
androidTestCompile 'au.com.dius:pact-jvm-consumer-junit_2.11:3.1.3'
androidTestCompile 'au.com.dius:pact-specification-test_2.11:3.1.3'
androidTestCompile 'au.com.dius:pact-jvm-matchers_2.11:3.1.3'
androidTestCompile 'au.com.dius:pact-jvm-consumer_2.11:3.1.3'
androidTestCompile 'au.com.dius:pact-jvm-consumer-specs2_2.11:3.1.3'
androidTestCompile 'au.com.dius:pact-jvm-model_2.11:3.1.3'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
testCompile 'junit:junit:4.12'
I’ve downgraded to
androidTestCompile 'au.com.dius:pact-jvm-consumer_2.10:2.4.2'
androidTestCompile 'au.com.dius:pact-jvm-consumer-junit_2.11:2.4.2'
still getting the same error:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
at com.android.dx.command.dexer.Main.processClass(Main.java:752)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:718)
at com.android.dx.command.dexer.Main.access$1200(Main.java:85)
at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1645)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:672)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:574)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Caused by: com.android.dx.cf.iface.ParseException: bad utf-8 byte a0 at offset 00000004
at com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:374)
at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:262)
at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:294)
at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)
at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)
at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
at com.android.dx.command.dexer.Main.parseClass(Main.java:764)
at com.android.dx.command.dexer.Main.access$1500(Main.java:85)
at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1684)
at com.android.dx.command.dexer.Main.processClass(Main.java:749)
... 12 more
Caused by: java.lang.IllegalArgumentException: bad utf-8 byte a0 at offset 00000004
at com.android.dx.rop.cst.CstString.throwBadUtf8(CstString.java:171)
at com.android.dx.rop.cst.CstString.utf8BytesToString(CstString.java:143)
at com.android.dx.rop.cst.CstString.<init>(CstString.java:200)
at com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:371)
... 25 more
1 error; aborting
Error:Execution failed for task ':app:preDexDebugAndroidTest'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Pact-JVM fails with Android · Issue #201 - GitHub
We are trying to setup Pact for a new project using iOS and Android consumers. We are facing issues with Android when running...
Read more >Pact with iOS and Android
We are trying to setup Pact for a new project using iOS and Android consumers. We are facing issues with Android when running...
Read more >Android PACT demo application - java - Stack Overflow
I studied the pact workshop for android (link) & jvm (link) both. I gone through all the steps of this two workshops. I...
Read more >pact-jvm
I'm looking at https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#example-of-http-test specifically the `toStateWithData(Map data)` method.
Read more >JitPack | Publish JVM and Android libraries
JitPack makes it easy to release your Java or Android library. Publish straight from GitHub or Bitbucket.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is not with using pact-jvm with Android consumer apps (I have see some successful projects using it), it is with running the mock server and pact tests in the Android simulator. If the tests are run outside, then everything works fine.
I have been converting the Scala code to Groovy, but I feel that a statically typed language would suite better so I might look at Kotlin (which works well with Android). Once the conversion is done, then the tests can be run in the simulator (although I don’t see the value of doing this).
Closing this as it does not make sense to run the pact mock server and tests in the Android simulator.