Bug 37499 - TypeLoadException when launching a WebView when Android target = Min Android ver = 4.4
Summary: TypeLoadException when launching a WebView when Android target = Min Android ...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Chris King
URL:
Depends on:
Blocks:
 
Reported: 2016-01-08 00:26 UTC by bobme981
Modified: 2017-06-19 21:41 UTC (History)
8 users (show)

Tags: BXCU
Is this bug a regression?: ---
Last known good build:


Attachments
repro solution (52.05 KB, application/x-zip-compressed)
2016-01-08 00:26 UTC, bobme981
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description bobme981 2016-01-08 00:26:04 UTC
Created attachment 14493 [details]
repro solution

See attached solution for repro.

Simple Xamarin.Forms app that shows a WebView on its main page.

STEPS:
Set the following in the Droid project options:
  Target framework = 4.4
  Min Android Version = 4.4
  Target Android Version = 4.4

RESULT:
Build error: C:\...\WebViewNullException\Droid\obj\Debug\resourcecache\26F88637DDCCF72DF581B1A2CF14E212\res\layout\abc_screen_toolbar.xml(0,0): Error APT0000: No resource identifier found for attribute 'touchscreenBlocksFocus' in package 'android' (APT0000) (WebViewNullException.Droid)

I don't understand this error, but was able to resolve it by setting:

  Target Android Version = 6.0

Notice that Target framework and Min Android version are still the same, so no runtime version checks should be necessary.

RESULT:
Build -> no error
Run -> crash on startup

Exception:
TypeLoadException: Could not load type 'Xamarin.Forms.Platform.Android.FormsWebChromeClient'

Call stack:
System.Diagnostics.Debugger.Mono_UnhandledException_internal() in 
System.Diagnostics.Debugger.Mono_UnhandledException( Parameters) in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122
object.5b528b84-b8b3-483f-8acc-f8746451fb95( Parameters) in 
Xamarin.Forms.Platform.Android.WebViewRenderer.OnElementChanged( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.WebView>.SetElement( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.WebView>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement( Parameters) in 
Xamarin.Forms.Platform.Android.Platform.CreateRenderer( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementPackager.Load( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.Page>.SetPackager( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.Page>.SetElement( Parameters) in 
Xamarin.Forms.Platform.Android.VisualElementRenderer<Xamarin.Forms.Page>.Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement( Parameters) in 
Xamarin.Forms.Platform.Android.Platform.CreateRenderer( Parameters) in 
Xamarin.Forms.Platform.Android.Platform.AddChild( Parameters) in 
Xamarin.Forms.Platform.Android.Platform.SetPage( Parameters) in 
Xamarin.Forms.Platform.Android.FormsApplicationActivity.InternalSetPage( Parameters) in 
Xamarin.Forms.Platform.Android.FormsApplicationActivity.SetMainPage( Parameters) in 
Xamarin.Forms.Platform.Android.FormsApplicationActivity.LoadApplication( Parameters) in 
WebViewNullException.Droid.MainActivity.OnCreate( bundle) in c:\Scratch\Repros\WebViewNullException\Droid\MainActivity.cs:22
Android.App.Activity.n_OnCreate_Landroid_os_Bundle_( Parameters) in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.App.Activity.cs:2475
object.5b528b84-b8b3-483f-8acc-f8746451fb95( Parameters) in 

App output:
[] TypeRef ResolutionScope not yet handled (188) for .FileChooserParams in image /storage/emulated/0/Android/data/com.companyname.webviewnullexception/files/.__override__/Xamarin.Forms.Platform.Android.dll
[Mono] The class FileChooserParams could not be loaded, used in 
[] Could not load signature of Xamarin.Forms.Platform.Android.FormsWebChromeClient:OnShowFileChooser due to: Failed for unknown reasons. assembly: type:FileChooserParams member:<none>
[Mono] Assembly Ref addref Mono.Android[0xb8b7c990] -> System.Runtime.Serialization[0xb8f49300]: 3


FYI: While attempting to narrow down this issue, I encountered a case where a try/catch block would catch the exception, and the exception itself would be null, but I am no longer able to reproduce this behavior. Very strange.
Comment 1 bobme981 2016-01-08 00:31:43 UTC
WORKAROUND:

Set the following:
  Target framework = "Use latest installed version (6.0)"

RESULT:
The WebView now loads without the TypeLoadException error, but I must now be careful not to use any 4.4+ APIs or the app may fail at runtime.
Comment 2 Al Clark [MSFT] 2016-01-14 14:45:47 UTC
Could you also please attach your full version information?

Visual Studio
Help -> About Microsoft Visual Studio -> Copy Info [button]

Xamarin Studio in OS X
Xamarin Studio -> About Xamarin Studio -> Show Details -> Copy Information [button]
Comment 3 Paul Johnson 2016-01-15 11:09:46 UTC
I'm currently seeing this too

=== Xamarin Studio ===

Version 5.10.2 (build 49)
Installation UUID: f3d1a29c-1ba2-4a83-a193-1087efe91a85
Runtime:
	Mono 4.2.2 (explicit/7b87787)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402020010

=== Xamarin.Profiler ===

Version: 0.24.0.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.1.12 (Business Edition)
Hash: 78c6cd3
Branch: master
Build date: 2015-12-17 18:29:42-0500

=== Xamarin.Android ===

Version: 6.0.1.5 (Business Edition)
Android SDK: /Users/PFJ/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1 rc1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.1.5 (Starter Edition)

=== Build Information ===

Release ID: 510020049
Git revision: deed4cd240ff3611c8742bbc62296e207f46173d
Build date: 2015-12-17 11:13:36-05
Xamarin addins: 8bd975e7b465f6fe812b64d736f3b7e8c1a79a3e
Build lane: monodevelop-lion-cycle6-c6sr1

=== Operating System ===

Mac OS X 10.11.4
Darwin Pauls-iMac.local 15.4.0 Darwin Kernel Version 15.4.0
    Sun Jan  3 21:35:22 PST 2016
    root:xnu-3248.40.155~11/RELEASE_X86_64 x86_64
Comment 4 Chris King 2017-06-19 17:09:45 UTC
Assigned to you as you were last to requeste info for this bug.
Comment 5 Samantha Houts [MSFT] 2017-06-19 21:41:41 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we believe it no longer affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction. 
 
Here are some reproduction best practices: https://gist.github.com/jassmith/92405c300e54a01dcc6d