Search code examples
androidreflectioninvocationtargetexception

`InvocationTargetException` while calling Class.forname


I am using the following code:

    try {
        Class.forName("android.webkit.WebView")
                .getMethod("onPause", (Class[]) null)
                .invoke(myWebView, (Object[]) null);

    } catch (Exception cnfe) {
        cnfe.getCause();
        Logger.appendErrorLog(cnfe.getMessage(), TAG);
    }

I am getting InvocationTargetException while executing the above code. What is the problem?


Solution

  • Please check the dependencies you are using in pom.xml. There might be some dependencies conflicting with one another. Make sure it is not caused becaues of any dependencies.