Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java 17 incompatibility - UnsupportedOperationException: class redefinition failed: attempted to delete a method #384

Closed
mateuszkwiecinski opened this issue Mar 11, 2022 · 23 comments
Assignees
Milestone

Comments

@mateuszkwiecinski
Copy link

mateuszkwiecinski commented Mar 11, 2022

👋
I wanted to give Paparazzi a try and I after first couple of bumps I think I got into a point I can say I have proper setup. Which:
a) if used with default theme - records png file with placeholder over places where material views should be
b) if used with Material Theme - results in #380
So I assume that's expected at this point.
The results above I got only after downgrading Java to previous LTS version (11). If I use current LTS (17) I get:

java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at net.bytebuddy.utility.Invoker$Dispatcher.invoke(Unknown Source)
	at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForNonStaticMethod.invoke(JavaDispatcher.java:1013)
	at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1142)
	at net.bytebuddy.dynamic.loading.$Proxy35.retransformClasses(Unknown Source)
	at net.bytebuddy.dynamic.loading.ClassReloadingStrategy$Strategy$2.apply(ClassReloadingStrategy.java:408)
	at net.bytebuddy.dynamic.loading.ClassReloadingStrategy.load(ClassReloadingStrategy.java:236)
	at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:100)
	at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6154)
	at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:34)
	at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:22)
	at app.cash.paparazzi.agent.InterceptorRegistrar.registerMethodInterceptors(InterceptorRegistrar.kt:39)
	at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:15)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy2/jdk.proxy2.$Proxy5.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

Looking at your CI config you don't support anything above java 15. I couldn't find the stack trace nor issue mentioning java 17 so I thought it's worth reporting here.

Version used: 1.0.0-20220311.182942-63.pom
compileSdk 31
gradle 7.4.1
agp 7.1.2

java --version
openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8)
OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)
@jrodbx
Copy link
Collaborator

jrodbx commented Mar 19, 2022

Tried on Java 17, and ran into https://youtrack.jetbrains.com/issue/KT-45545.

So gotta bump Kotlin-Compose first.

@vyguera
Copy link

vyguera commented Mar 23, 2022

I also wanted to give Paparazzi a try. As it claims to not use any emulator I wanted to use it in a unit test with fragment-testing library, but I got a similar error executing my proof of concept test with AndroidJunit4.

import androidx.test.ext.junit.runners.AndroidJUnit4
import app.cash.paparazzi.Paparazzi
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class TextInputViewTest {
  @get:Rule
  val paparazzi = Paparazzi()

  @Test
  fun screenshotTest() {
  }
}

It just fails with an empty test. And the exception is:

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
	at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at net.bytebuddy.utility.Invoker$Dispatcher.invoke(Unknown Source)
	at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForNonStaticMethod.invoke(JavaDispatcher.java:1019)
	at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1149)
	at net.bytebuddy.dynamic.loading.$Proxy56.retransformClasses(Unknown Source)
	at net.bytebuddy.dynamic.loading.ClassReloadingStrategy$Strategy$2.apply(ClassReloadingStrategy.java:399)
	at net.bytebuddy.dynamic.loading.ClassReloadingStrategy.load(ClassReloadingStrategy.java:227)
	at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
	at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6161)
	at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:34)
	at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:22)
	at app.cash.paparazzi.agent.InterceptorRegistrar.registerMethodInterceptors(InterceptorRegistrar.kt:39)
	at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:15)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:575)
	at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:278)
	at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

@jrodbx
Copy link
Collaborator

jrodbx commented Mar 23, 2022

Makes sense. At the moment, support is upper-limited to JDK 15.

@vyguera
Copy link

vyguera commented Mar 23, 2022

Ah I forgot to say that even though I have java 17 installed this is run on Android Studio that has its own JDK 11 embedded, and Gradle also is configured to compile and make it compatible with java 1.8:

kotlinOptions {
   jvmTarget = JavaVersion.VERSION_1_8.toString()
 }

 compileOptions {
   sourceCompatibility = JavaVersion.VERSION_1_8
   targetCompatibility = JavaVersion.VERSION_1_8
 }

I also tried with VERSION_11 with the same result

@jrodbx
Copy link
Collaborator

jrodbx commented Mar 24, 2022

I recently encountered something similar trying to learn more about this issue and when I hit Cmd-, and went to Gradle settings, I found that Android Studio was still pointing to JDK 17.

That's the workaround for the moment, unfortunately.

@vyguera
Copy link

vyguera commented Mar 24, 2022

This is something I already tried, and it was promising at the beginning making the test to pass. It even created a report in build directory. But I made some minor changes and subsequent executions failed. I reverted to the same code but since then I always got that error. No matters what I do, still happens the same.

Right now I have changed my JDK to JDK 17 with no luck. After that I also changed my kotlinOptions and compileOptions to also use VERSION_17, and again: fails

@vyguera
Copy link

vyguera commented Mar 24, 2022

Maybe mine is not the same problem and I should open a new issue. But the point with my sample is that it works when I don't use the AndroidJUnit4 runner

@takahirom
Copy link

takahirom commented May 21, 2022

I couldn't get it to work with JDK 11 either, I suspect it's a compatibility issue with Robolectric.

Write down the reproduction procedure.

First, check the JDK version.

@RunWith(AndroidJUnit4::class)
class ExampleUnitTest {
//    @get:Rule
//    val paparazzi = Paparazzi()

    @Test
    fun addition_isCorrect() {
        println(System.getProperty("java.version"))
    }
}

./gradlew testDebug

16.0.2

brew install openjdk@11
./gradlew -Dorg.gradle.java.home="/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home" testDebugUnitTest

11.0.15

reproduction procedure

@RunWith(AndroidJUnit4::class)
class ExampleUnitTest {
    @get:Rule
    val paparazzi = Paparazzi() // ← Comment in !!

    @Test
    fun addition_isCorrect() {
        println(System.getProperty("java.version"))
    }
}

./gradlew -Dorg.gradle.java.home="/opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk/Contents/Home" testDebugUnitTest

com.example.paparazziwithrobolectric.ExampleUnitTest > jvm FAILED
java.lang.UnsupportedOperationException at InstrumentationImpl.java:-2

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:167)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at net.bytebuddy.utility.Invoker$Dispatcher.invoke(Unknown Source)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForNonStaticMethod.invoke(JavaDispatcher.java:1013)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1142)
        at net.bytebuddy.dynamic.loading.$Proxy52.retransformClasses(Unknown Source)
        at net.bytebuddy.dynamic.loading.ClassReloadingStrategy$Strategy$2.apply(ClassReloadingStrategy.java:408)
        at net.bytebuddy.dynamic.loading.ClassReloadingStrategy.load(ClassReloadingStrategy.java:236)
        at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:100)
        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6154)
        at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:34)
        at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:22)
        at app.cash.paparazzi.agent.InterceptorRegistrar.registerMethodInterceptors(InterceptorRegistrar.kt:39)
        at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:15)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:591)
        at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:274)
        at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:88)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)

Repository

https://github.com/takahirom/paparazzi-with-robolectric

@apkelly
Copy link

apkelly commented Sep 27, 2022

I had the same error

java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the schema (add/remove fields)

I fixed it by removing this line from my test class.

@RunWith(AndroidJUnit4::class)

@AfzalivE
Copy link

AfzalivE commented Nov 17, 2022

Try running from terminal. Android Studio might still be using JDK > 11 for its runtime. That's what worked for me.

@alexvanyo
Copy link
Contributor

The latest 8.0 alphas of AGP now require JDK 17, meaning that there is an upcoming incompatibility with Paparazzi and AGP.

@TWiStErRob
Copy link
Contributor

TWiStErRob commented Jan 6, 2023

AGP will require JDK 17, which means that gradlew (JAVA_HOME and AS Settings) has to use JDK 17 (note, AS itself doesn't!), but Gradle added beautiful toolchain support (and even before that it was possible) to be able to easily define JDK running different tasks. So with a few lines we should be able to still work around this:

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions.jvmTarget = "11" // lower byte-code level so that Test can load classes.
}
tasks.named("test").configure {
    javaLauncher = javaToolchains.launcherFor {
      languageVersion = JavaLanguageVersion.of(11)
    }
}

@alexvanyo
Copy link
Contributor

alexvanyo commented Jan 7, 2023

Woah, that's really cool!

Can confirm with the above workaround that Paparazzi will run with the latest AGP alpha, using JDK 17 for ./gradlew, but configuring the Paparazzi tests to use JDK 11.

@yaseen-sathakk
Copy link

yaseen-sathakk commented Feb 24, 2023

Thanks for sharing the workaround @TWiStErRob . I'm trying to use paparazzi for one of the project. As @alexvanyo mentioned above Android Studio Flamingo will be using JDK 17 by default. I'm requesting to see whether there is any planned update to support JDK 17?

@eygraber
Copy link

eygraber commented Mar 3, 2023

AGP Flamingo Beta 3
Gradle 8.0.1
Android JUnit 1.1.5
Androidx Test Core 1.5.0
Android Test Runner 1.5.2
Espresso 3.5.1
Paparazzi 1.2.0 (and 1.3.0-SNAPSHOT)
Robolectric 4.9.2

Running recordPaparazzi works with JDK 17 if I don't use RunWith(AndroidJUnit4) or have robolectric tests in the same source set:

JDK 17:

  • @RunWith(AndroidJUnit4::class) -> UnsupportedOperationException
  • Tests in same source set use @RunWith(RobolectricTestRunner::class) -> NoClassDefFoundError at EspressoLink.android.kt:92 for every robolectric test
  • Otherwise success

JDK 11:

  • @RunWith(AndroidJUnit4::class) -> UnsupportedOperationException
  • Tests in same source set use @RunWith(RobolectricTestRunner::class) -> NoClassDefFoundError at EspressoLink.android.kt:92 for every robolectric test
  • Otherwise UnsupportedClassVersionError at paparazzi.snapshot (maybe because of Compose?)

For JDK 11 configuring toolchain like this:

android {
  compileOptions {
    targetCompatibility = JavaVersion.VERSION_11
  }
}

tasks.withType<KotlinCompile>().configureEach {
  kotlinOptions.jvmTarget = "11" // lower byte-code level so that Test can load classes.
}

tasks.withType<Test>().configureEach {
  javaLauncher.set(
    javaToolchains.launcherFor {
      languageVersion.set(JavaLanguageVersion.of(11))
    }
  )
}

@jrodbx jrodbx added this to the 1.3 milestone Apr 15, 2023
@hardysim
Copy link

I'm not able to get the workaround working but one can continue to use AGP 7.4.2 for AS flamingo as well (only AGP 8 requires java 17). Maybe this helps someone until paparazzi has proper support for this use case with java 17 and RunWith.

@ThomasRichtsfeld
Copy link

The workaround also doesn't work for us

@technoir42
Copy link

Another workaround that doesn't require JDK 11:

android {
    testOptions {
        unitTests.all {
            useJUnitPlatform {
                // TODO: Remove when https://github.com/cashapp/paparazzi/issues/384 is fixed
                if (JavaVersion.current() >= JavaVersion.VERSION_13) {
                    jvmArgs "-XX:+AllowRedefinitionToAddDeleteMethods"
                }
            }
        }
    }
}

@geoff-powell
Copy link
Collaborator

so based on all the input, the issue here is using @RunWith(AndroidJUnit4::class) or Robolectric with Paparazzi which is tracked by this issue #425

I'm going to leave this issue open for a bit until the PR above is merged, but paparazzi is now on AGP 8.0 and built with Java 17 and is working as expected.

@jrodbx jrodbx removed this from the 1.3.1 milestone May 19, 2023
@jrodbx jrodbx added this to the 1.3 milestone May 19, 2023
@andersaction
Copy link

I still had the problem using jdk 17, kotlin 1.8.21, gradle 8 and paparazzi 1.3.0.
java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method
Seems like it was caused by test coverage being enabled.

Removing this fixed it:

    buildTypes {
        debug {
            testCoverageEnabled true
            enableUnitTestCoverage true
        }
    }

@rohilchodankar
Copy link

I am still seeing the same error even after removing test Coverage flags and the test does not have @RunWith(AndroidJUnit4::class) or Robolectric

I am using JDK 17, kotlin 1.8.21, Gradle 8.1.1, AGP 8.0.2, paparazzi 1.3.0.

java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at java.instrument/sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:169)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at net.bytebuddy.utility.Invoker$Dispatcher.invoke(Unknown Source)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$Dispatcher$ForNonStaticMethod.invoke(JavaDispatcher.java:1032)
        at net.bytebuddy.utility.dispatcher.JavaDispatcher$ProxiedInvocationHandler.invoke(JavaDispatcher.java:1162)
        at net.bytebuddy.dynamic.loading.$Proxy38.retransformClasses(Unknown Source)
        at net.bytebuddy.dynamic.loading.ClassReloadingStrategy$Strategy$2.apply(ClassReloadingStrategy.java:399)
        at net.bytebuddy.dynamic.loading.ClassReloadingStrategy.load(ClassReloadingStrategy.java:227)
        at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
        at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6317)
        at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:34)
        at app.cash.paparazzi.agent.InterceptorRegistrar$addMethodInterceptors$1.invoke(InterceptorRegistrar.kt:22)
        at app.cash.paparazzi.agent.InterceptorRegistrar.registerMethodInterceptors(InterceptorRegistrar.kt:39)
        at app.cash.paparazzi.agent.AgentTestRule$apply$1.evaluate(AgentTestRule.kt:15)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
        at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
        at jdk.proxy2/jdk.proxy2.$Proxy5.processTestClass(Unknown Source)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
        at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
        at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
        at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)

@dmitry-ryadnenko-izettle

Removing jacoco plugin solves this for me. Not clear how to solve this with jacoco enabled though.

@loutry
Copy link

loutry commented Jun 23, 2023

I'm also still getting this issue without using @RunWith(AndroidJUnit4::class) or Robolectric and having code coverage and JaCoCo enabled. If I disabled JaCoCo and test coverage then it works.

I open a new issue #955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests