WebView: JavaScript interface method is undefined Android Origin: On your device OSI layer 7 · Application Last updated 25 Nov 2026

Uncaught TypeError: Android.showToast is not a function

The addJavascriptInterface object isn't reachable or the method lacks @JavascriptInterface.

Exact message you may see Uncaught TypeError Android.showToast is not a functionJavascriptInterface not workingaddJavascriptInterface undefinedUncaught TypeError: Android.showToast is not a function (WebView console, line 1)
Seen on: Android Kotlin

Meaning

From API 17 methods must be annotated @JavascriptInterface. Also JavaScript must be enabled, the name must match, and the interface must be added before loading the URL.

Common causes

  • Missing @JavascriptInterface
  • JavaScript disabled
  • Interface added after loadUrl

⚡ Quick fix

  1. Annotate the method
  2. settings.javaScriptEnabled = true
  3. Add the interface before loading

Detailed fix by platform

Kotlin

  1. kotlin
    webView.settings.javaScriptEnabled = true
    webView.addJavascriptInterface(Bridge(), "Android")

How to diagnose

  1. Annotation — present?
  2. JS — enabled?
  3. Order — before load?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

AccessibilityService restricted setting (Android 13) — Restricted setting: For your security, this setting is currently unavailable (Android)AccessibilityService …Android resource linking failed — AAPT: error: resource x (aka y) not found — Android resource linking failed (Android)Android resource link…android:attr/lStar not found — AAPT: error: resource android:attr/lStar not found (Android)android:attr/lStar no…CalledFromWrongThreadException — CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views (Android)CalledFromWrongThread…Error building the app bundle — Execution failed for task ':app:bundleRelease'. Error while executing bundletool (Android)Error building the ap…Guideline 4.2: Minimum Functionality — Guideline 4.2 - Design - Minimum Functionality: your app provides a limited user experience as it is not sufficiently different from a mobile browser (iOS)Guideline 4.2: Minimu…ITMS-90809: Deprecated API Usage — UIWebView — ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs. (iOS)ITMS-90809: Deprecate…WebView: net::ERR_SSL_PROTOCOL_ERROR / blank page — Web page not available net::ERR_CLEARTEXT_NOT_PERMITTED / ERR_SSL_PROTOCOL_ERROR (Android)WebView: net::ERR_SSL…WebView: …

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.