donderdag 16 oktober 2014

Robolectric + Google Play Service 5.x = java.lang.VerifyError

When I upgraded my application recently to include Play Services 5.x (for Wearable integration) I ran into the infamous VerifyError.

Thanks to this Google post, I could easily fix the issue.

In short, when you have this in your build file:
    //keep GMS play services at 4.4, 5.x only works with support-v4:21.+
    //compile ''
    compile ''

    compile 'org.bouncycastle:bcprov-jdk16:1.46'

Make sure to include:
tasks.whenTaskAdded { theTask ->
    def taskName =
    //map "testLocalDebug" to your taskName!!
    if ("testLocalDebug".toString().equals(taskName)) {
         * Listen for when robolectric adds the 'testDebug' task and when it does, add the -noverify
         * option to that task's jvmArgs.  This allows us to turn off byte code verification when
         * running our unit tests.

To avoid:
java.lang.VerifyError: Expecting a stackmap frame at branch target 69
Exception Details:
    com/google/android/gms/gcm/GoogleCloudMessaging.()V @31: goto
    Expected stackmap frame at this location.
    0000000: b801 b54c 2ab7 011d 2ab6 0120 1301 2203
    0000010: 1202 b801 284d 2cc7 000b 2b10 2c04 54a7

Geen opmerkingen:

Een reactie plaatsen