Fix "Couldn't desugar invokedynamic" when running androidConnectedTest : <p>My Android app uses Java 8 lambdas like so:</p>

<pre><code>myView.setOnClickListener(view -&gt; someMethod());
</code></pre>

<p>Everything works fine with the above when building the app or running unit tests. However, when I run <code>./gradlew connectedAndroidTest</code>, I get the following error:</p>

<pre><code>Execution failed for task ':myModule:transformClassesWithDesugarForDebugAndroidTest'.

Exception in thread "main" java.lang.IllegalStateException: Couldn't desugar invokedynamic for com/.../MyActivity.onClick using java/lang/invoke/LambdaMetafactory.metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; (6) with arguments [(Landroid/view/View;)V, com/.../MyActivity.lambda$onViewBound$0(Landroid/view/View;)V (7), (Landroid/view/View;)V]
    at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:474)
    at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1623)
    at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
    at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
    at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:477)
    at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:361)
    at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:314)
    at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:711)
Caused by: java.lang.IllegalAccessException: no such method: com...MyActivity.lambda$onViewBound$0(View)void/invokeSpecial
    at java.lang.invoke.MemberName.makeAccessException(MemberName.java:867)
    at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1003)
    at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1386)
    at java.lang.invoke.MethodHandles$Lookup.findSpecial(MethodHandles.java:1004)
    at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.toMethodHandle(LambdaDesugaring.java:670)
    at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.toJvmMetatype(LambdaDesugaring.java:647)
    at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:408)
    ... 8 more
Caused by: java.lang.NoClassDefFoundError: com/.../databinding/MyActivityBinding
    at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
    at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:975)
    at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:1000)
    ... 13 more
Caused by: java.lang.ClassNotFoundException: Class com...databinding.MyActivityBinding not found
    at com.google.devtools.build.android.desugar.HeaderClassLoader.findClass(HeaderClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 16 more
</code></pre>

<p>Note that removing the lambda makes it build again. Any idea on what could be happening and how to fix it?</p>
