I am trying to create a WebView dynamically using the following code:
mWebView = new WebView(this);
mWebView.setId(R.id.webview);
mWebView.setVerticalScrollBarEn
NOTE: The question "what api level do you build for?" is VERY different from the question "what is the minimum api level that you target?".
Given the behaviour you have described, it suggests you are building with api level >=11 and testing on a device that is api level <11.
Because .setLayerType is only available from api level 11 onwards, building with api level >=11 will build fine, but if you are not using compatibility tricks such as reflection or: Compatibility.getCompatibility().setWebSettingsCache(webSettings); ...then when you test on a device that is api level <11 you will get a crash because that method is not supported. On the other hand, if you test on a device of api level >=11 you should find it works.