Pact with iOS and Android

316 views
Skip to first unread message

João Medrado

unread,
Dec 14, 2015, 6:26:38 PM12/14/15
to Pact
Hello,

We 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?

Cheers,
João

Ronald Holshausen

unread,
Dec 14, 2015, 6:32:04 PM12/14/15
to João Medrado, Pact
Hi João,

You're the first person I've heard from trying to use pact with Android, so you might be heading out on to new ground. Can you provide some more information as to what problems you are having with Scala and Android?

--
You received this message because you are subscribed to the Google Groups "Pact" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pact-support...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ronald Holshausen

DiUS Computing Pty Ltd

Level 10, 99 Queens Street
Melbourne, VIC 3000

Phone: +61 3 9008 5400
Mobile: +61 413 162 439

http://www.diuscomputing.com.au

Bethany Skurrie

unread,
Dec 14, 2015, 7:53:24 PM12/14/15
to Ronald Holshausen, João Medrado, Pact
Try pinging Andy on the pact swift repo about the iOS 7 issue.

Bethany Skurrie
Software Developer

DiUS Computing Pty. Ltd.
where ideas are engineered

Mobile: +61 415 413 713

www.dius.com.au

This email is intended solely for the use of the addressee and may contain information that is confidential or privileged. If you receive this email in error please notify the sender and delete the email immediately.

João Medrado

unread,
Dec 14, 2015, 8:17:17 PM12/14/15
to Pact, rhols...@dius.com.au, jca...@gmail.com
Thanks, I will see with the iOS dev if he can ping Andy.

I didn't know we could actually use Scala with Android, we are doing the setup and installing Scala, I'll let you know how we go. 

I guess it would be nice to not have a Scala dependency when running the Java consumer though or at least have a separate Scala and Java implementations.

Cheers
João

João Medrado

unread,
Dec 14, 2015, 11:19:01 PM12/14/15
to Pact, rhols...@dius.com.au
No luck integrating Android Studio with Scala, we install the Scala SDK and tried different settings and tutorials but at the end Android Studio still thinks the Scala files are Java files and fails to compile.

Ronald Holshausen

unread,
Dec 14, 2015, 11:21:06 PM12/14/15
to João Medrado, Pact
Can you just use the published JAR files and not have to compile the Scala files? Or are you referring to the class file translation to the Android VM?

João Medrado

unread,
Dec 14, 2015, 11:31:54 PM12/14/15
to Pact, jca...@gmail.com
This is what we get using the published JAR:

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 class file magic (cafebabe) or version (0034.0000)
	at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
	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
1 error; aborting
Error:Execution failed for task ':app:preDexDevelopDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

Ronald Holshausen

unread,
Dec 14, 2015, 11:40:16 PM12/14/15
to João Medrado, Pact
what version of pact-jvm are you using?

João Medrado

unread,
Dec 14, 2015, 11:48:23 PM12/14/15
to Pact, jca...@gmail.com
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'

Ronald Holshausen

unread,
Dec 14, 2015, 11:56:27 PM12/14/15
to João Medrado, Pact
Try the 2.x version which is JDK 6 based, the 3.x versions are JDK 8 based.

João Medrado

unread,
Dec 15, 2015, 1:01:15 AM12/15/15
to Pact, jca...@gmail.com
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

Ronald Holshausen

unread,
Dec 15, 2015, 1:49:33 AM12/15/15
to João Medrado, Pact

That was just a hunch that maybe the java 8 byte code was the problem. I'll have to dig deeper. There has been people who have been using Scala with Android so it is possible.

Ronald Holshausen

unread,
Dec 15, 2015, 10:00:24 PM12/15/15
to João Medrado, Pact
I've raised this as an issue: https://github.com/DiUS/pact-jvm/issues/201

Natasha Badillo

unread,
Jan 7, 2016, 11:22:36 AM1/7/16
to Pact, jca...@gmail.com
Not sure how much help I can offer here, but I do know that we are using pact-jvm with our Android project and never had any issues with Scala at all. We wrote the tests some time ago, using 

testCompile ('au.com.dius:pact-jvm-consumer-junit_2.11:2.2.12')

Was something introduced more recently that might have caused the issue you're seeing?

Ronald Holshausen

unread,
Jan 7, 2016, 8:59:28 PM1/7/16
to Natasha Badillo, Pact, João Medrado
That is good to hear. I'll try that version and see if I can pinpoint the issue.

Ronald Holshausen

unread,
Jan 8, 2016, 11:54:07 PM1/8/16
to Pact, jca...@gmail.com
The difference is that João is using androidTestCompile, which results in the pact libraries being converted to DEX format so the tests can be run in the emulator.

Natasha Badillo

unread,
Jan 12, 2016, 12:19:21 PM1/12/16
to Pact, jca...@gmail.com
Ahh, that makes sense. We use Robolectric for our unit tests, which allows us to avoid having to use the emulator. FWIW, it really does speed up the process considerably ... and it works with Pact! The only catch is that we had to exclude the Apache httpclient library from both Pact and Robolectric, and use httpclient-android instead. But it looks like he was already using that. :)

João, I don't know if it's feasible for you to look at different frameworks at this point, but if you can I would suggest taking a look at Robolectric and see if it will work for you.
Reply all
Reply to author
Forward
0 new messages