UnitTest fail with java.lang.NoSuchMethodError

81 views
Skip to first unread message

Yuanyuan Zhang

unread,
Jul 7, 2021, 5:21:00 PM7/7/21
to Robolectric

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?

Reply all
Reply to author
Forward
0 new messages