Bug 40962 - System.NotSupportedException: Unable to activate instance of type Android.Webkit.WebView from native handle
Summary: System.NotSupportedException: Unable to activate instance of type Android.Web...
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 5.1
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2016-05-09 11:36 UTC by Jakub Holovsky
Modified: 2017-10-04 15:14 UTC (History)
2 users (show)

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


Attachments

Description Jakub Holovsky 2016-05-09 11:36:48 UTC
In our activity where we use WebView we received following exception:

java.lang.Throwable: System.NotSupportedException: Unable to activate instance of type Android.Webkit.WebView from native handle c00001d ---> System.MissingMethodException: No constructor found for Android.Webkit.WebView::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown.
Java.Lang.Error: Exception of type 'Java.Lang.Error' was thrown.

  --- End of managed exception stack trace ---
java.lang.Error: Java callstack:
	at md5d692d05b2b6590ccfeea31a48064f088.TopUpActivity.n_onCreate(Native Method)
	at md5d692d05b2b6590ccfeea31a48064f088.TopUpActivity.onCreate(TopUpActivity.java:33)
	at android.app.Activity.performCreate(Activity.java:5998)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2446)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2557)
	at android.app.ActivityThread.access$800(ActivityThread.java:176)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
	at android.os.Handler.dispatchMessage(Handler.java:111)
	at android.os.Looper.loop(Looper.java:194)
	at android.app.ActivityThread.main(ActivityThread.java:5578)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)

  --- End of inner exception stack trace ---
  at Java.Interop.TypeManager.CreateProxy (System.Type type, IntPtr handle, JniHandleOwnership transfer) [0x00000] in <filename unknown>:0 
  at Java.Interop.TypeManager.CreateInstance (IntPtr handle, JniHandleOwnership transfer, System.Type targetType) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
at Java.Interop.TypeManager.CreateInstance (intptr,Android.Runtime.JniHandleOwnership,System.Type) <0x006d0>
at Java.Lang.Object.GetObject (intptr,Android.Runtime.JniHandleOwnership,System.Type) <0x002c3>
at Java.Lang.Object._GetObject<Android.Views.View> (intptr,Android.Runtime.JniHandleOwnership) <0x0004b>
at Java.Lang.Object.GetObject<Android.Views.View> (intptr,Android.Runtime.JniHandleOwnership) <0x0002b>
at Android.Views.ViewGroup.GetChildAt (int) <0x00187>
at Psonar.Apps.Droid.PayPerPlay.FontUtils.SetRobotoFont (Android.Content.Context,Android.Views.View) <0x000ab>
at Psonar.Apps.Droid.PayPerPlay.FontUtils.SetRobotoFont (Android.Content.Context,Android.Views.View) <0x000b7>
at Psonar.Apps.Droid.PayPerPlay.FontUtils.SetRobotoFont (Android.Content.Context,Android.Views.View) <0x000b7>
at Psonar.Apps.Droid.PayPerPlay.FontUtils.SetRobotoFont (Android.Content.Context,Android.Views.View) <0x000b7>
at Psonar.Apps.Droid.PayPerPlay.FontUtils.SetRobotoFont (Android.Content.Context,Android.Views.View) <0x000b7>
at Psonar.Apps.Droid.PayPerPlay.FontUtils.SetRobotoFont (Android.Content.Context,Android.Views.View) <0x000b7>
at Psonar.Apps.Droid.PayPerPlay.TopUpActivity.OnCreate (Android.OS.Bundle) <0x000e7>
at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00063>
at (wrapper dynamic-method) object.428ee723-6dfe-4e2b-94de-13205f95e07f (intptr,intptr,intptr) <0x00027>

	at md5d692d05b2b6590ccfeea31a48064f088.TopUpActivity.n_onCreate(Native Method)
	at md5d692d05b2b6590ccfeea31a48064f088.TopUpActivity.onCreate(TopUpActivity.java:33)
	at android.app.Activity.performCreate(Activity.java:5998)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2446)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2557)
	at android.app.ActivityThread.access$800(ActivityThread.java:176)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
	at android.os.Handler.dispatchMessage(Handler.java:111)
	at android.os.Looper.loop(Looper.java:194)
	at android.app.ActivityThread.main(ActivityThread.java:5578)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)

In our activity we keep the WebView as a private field:

private WebView webView;

and dispose it OnDestroy:

protected override void OnDestroy()
        {
            base.OnDestroy();

            if (webView != null)
            {
                webView.Dispose();
                webView = null;
            }
        }


My configuration:

Microsoft Visual Studio Community 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Community

Visual Basic 2015   00322-20000-00000-AA253
Microsoft Visual Basic 2015

Visual C# 2015   00322-20000-00000-AA253
Microsoft Visual C# 2015

Visual C++ 2015   00322-20000-00000-AA253
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-20000-00000-AA253
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   5.204.60502.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015 (RC1 Update 1)   14.1.20203.0
ASP.NET and Web Tools 2015 (RC1 Update 1)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.8.2   14.0.20201.0
Azure App Service Tools v2.8.2

Common Azure Tools   1.7
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

DataFactoryProject   1.0
Microsoft Data Factory Package

GitHub.VisualStudio   1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JetBrains ReSharper Ultimate 10.0.2   Build 104.0.20151218.120627
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2016 JetBrains, Inc.

Microsoft Azure Data Factory Node Node   1.0
Azure Data Factory extension for Visual Studio Server Explorer.

Microsoft Azure HDInsight HQL Service   2.0.2900.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   2.0.2900.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.8
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.8.40211.2

NuGet Package Manager   3.4.3
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60311.1
Microsoft SQL Server Data Tools

TypeScript   1.8.30.0
TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   14.0.25208.00
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   3.11.1594.0 (a06d6d5)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.7.12 (53fce3730830417896a42f365a5ba35f1ee58d9d)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS   9.1.0.0 (023e4c64eb456050e86dac6953aa0a576a70ac91)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 1 Atsushi Eno 2016-05-10 09:04:58 UTC
-> general Java interop issue.
Comment 2 Jonathan Pryor 2016-05-18 20:34:27 UTC
> System.NotSupportedException: Unable to activate instance of type Android.Webkit.WebView from native handle c00001d ---> 
> System.MissingMethodException: No constructor found for Android.Webkit.WebView::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)

That would be...this constructor?

https://developer.xamarin.com/api/constructor/Android.Webkit.WebView.WebView/p/System.IntPtr/Android.Runtime.JniHandleOwnership/

As a guess, the linker was removing a constructor which shouldn't have been removed.

However, that was on Xamarin.Android 5.1. Xamarin.Android 6.0.4 is current stable, and 6.1 is in beta. Could you please retry this with a more recent product version?
Comment 3 Jon Douglas [MSFT] 2017-10-04 15:14:50 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.Android. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.

Note You need to log in before you can comment on or make changes to this bug.