Bug 29410 - Calling C# from JS results in a TypeError
Summary: Calling C# from JS results in a TypeError
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 5.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2015-04-26 23:12 UTC by Cody Beyer (MSFT)
Modified: 2017-09-12 19:04 UTC (History)
3 users (show)

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

Sample (21.66 KB, application/zip)
2015-04-26 23:13 UTC, Cody Beyer (MSFT)

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:

Description Cody Beyer (MSFT) 2015-04-26 23:12:43 UTC
### Description 

The attached sample app is based upon the Xamarin sample for calling C# from JS in an Android WebView. When ran on a device running Lollipop, an unhanded error is thrown as described in the below error text

### Error


### Sample


### Required Environment

Physical device running Android Lollipop

### Steps to Reproduce

1. Run attached sample on aforementioned physical device running lollipop
2. Click on "Show Toast"

### Expected Results 

The application show show a toast message saying, "This is a Toast from C#"

### Actual Results

Error is thrown as described above

### Version

=== Xamarin Studio ===

Version 5.9 (build 431)
Installation UUID: ad159da4-fe22-4bfe-8be6-52e4b844ec90
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.3.1 (7703)
Build 6D1002

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: c8648f0
Branch: master
Build date: 2015-04-21 12:22:24-0400

=== Xamarin.Mac ===

Version: (Business Edition)

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/beyerc/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 509000431
Git revision: 7560726734fc7267de2fa9abed2509968deefaa8
Build date: 2015-04-17 19:25:48-04
Xamarin addins: 2e772c734ab3148054eae7bf8949f340fdeb5e5e

=== Operating System ===

Mac OS X 10.10.3
Darwin Codys-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Cody Beyer (MSFT) 2015-04-26 23:13:12 UTC
Created attachment 10903 [details]
Comment 5 Cody Beyer (MSFT) 2015-04-27 12:15:20 UTC
This issue appears on a Nexus 5. 

It MAY be related to https://bugzilla.xamarin.com/show_bug.cgi?id=29365

Which means it may require a freshly updated Lollipop device, but I can not be certain as it is inconclusive at this point
Comment 6 Jonathan Pryor 2015-04-27 17:47:18 UTC
@Cody: I'm unable to repro on a Nexus 5 with Android 5.1 (API-22) and Xamarin.Android 5.1.0-115, while I am able to repro Bug #29365. I do not think that these are related.
Comment 7 Jonathan Pryor 2015-04-28 12:15:48 UTC
@Cody: Also, this message:

> Uncaught TypeError: undefined is not a function

*probably* means that `NativeInvoker` hasn't been defined/set before the JavaScript code executes. This *could* be the case if e.g. view.AddJavascriptInterface() were called *after* view.LoadData(). (That's not the case in Attachment #10903 [details], but that *could* be the case at some point during development.)
Comment 8 Jon Douglas [MSFT] 2017-09-12 19:04:27 UTC
I am no longer able to reproduce this on Lollipop with Xamarin.Android 7.4. Thus I am marking this issue as RESOLVED NOT_REPRODUCIBLE.