Question

When I am running my tests after changing some code, the previous state of the code is still being used when rerunning tests.

Running tests
Test running started
java.lang.NoSuchMethodError: com.example.app.support.ConfiguredWebViewClient.<init>
at com.example.app.support.ConfiguredWebViewClientTest.testOverrideUrlLoading(ConfiguredWebViewClientTest.java:7)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661)

Finish

The problem with the NoSuchMethodError above is that there IS no method by the name of testOverrideUrLoading. It was replaced by different methods. This implies that Android Studio is hanging onto old class files somehow.

Things which have no effect:
  • Invalidating caches and restarting
  • Cleaning the build (in Android Studio)
  • Rebuilding (in Android Studio)

When I perform run ./gradlew connectedInstrumentTest, the tests run successfully and the problem resolves in Android Studio.

I would like to know how to force this behavior while working in the IDE.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top