0

We are currently facing this NoSuchMethod Error when we want to create the unit test with Robolectric version 4.3.1 and Mockito version 2.18.3

Exceptions:

java.lang.NoSuchMethodError: 'void com.android.webview.chromium.WebViewChromium.<init>(com.android.webview.chromium.WebViewChromiumFactoryProvider, android.webkit.WebView, android.webkit.WebView$PrivateAccess, boolean)'

Here is the code we did:

mWebView = Mockito.spy(
            new WebviewChromium(
                mockWebViewChromiumProvider, webView, webView.new PrivateAccess(), false));

In BUILD.gn, we have included the "//android_webview/glue:glue_java" as dependency, we can successfully compile the code but it sounds like in the runtime, it refers to the another wrong jar, does someone know how to config the build file to use the correct jar or any ideas about how to solve this error?

Kate
  • 53
  • 1
  • 6

1 Answers1

0

did you check this followjng thread https://github.com/robolectric/robolectric/issues/5092 and this one I think you need open jdk 11 or 13 I recently had the same issue after adding open jdk 13 to android studio it solved my problem robolectric started working fine you can check following thread as well https://github.com/robolectric/robolectric/issues/5092

  • Thanks for quick response. Yes, I saw that post before. I'm on Androidx Test 1.2.0, so the solution mentioned in the tickets doesn't help. I checked my open jdk version, the version is 8, but I didn't use the android studio and I use the terminal to build and run the test. Will try with jdk 11 to see if it works. – Kate Jul 06 '21 at 21:24
  • @Kate did you fix issue tell us what the problem if my answer correct please mark as accepted answer if it is not please post your solution it will help for future readers – Jack Philips Jul 08 '21 at 10:27