question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using window.ReactNativeWebView on Android KitKat returns an empty object

See original GitHub issue

Bug description: I’m developing an app that consists of a webview and a few extra features based on postMessage/onMessage and injectJavascript. In order to be able to use the app, the webview should support these methods across all android versions. I’ve tried these methods on an emulator and a real device and when using the app in Android 4.4 window.ReactNativeWebView is an empty object: {} instead of an object with postMessage. That works for all versions greater than 4.4. I’ve also tried disabling proguard without success thinking that could be the problem as the window.ReactNativeWebView is based on the use of @JavascriptInterface annotation. I found it happens in debug and release variants indistinctly.

Expected behavior: I’m expecting window.ReactNativeWebView to behave the same way across all the android versions so the web can send data with postMessage and the app can receive that data.

Environment:

  • OS: Android
  • OS version: 4.4.2
  • react-native version: 0.61.5
  • react-native-webview version: 8.1.2
  • minSdkVersion = 18
  • compileSdkVersion = 28
  • targetSdkVersion = 28

Repository with repro: https://github.com/mikelros/ReactNativeWebViewKitKat Screenshots of that repository:

Android 4.4.2 android-442

Android 5.1 android-51

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
smontlouiscommented, Apr 15, 2020

NVM, it’s working only for android 5.0 and above

1reaction
mikelroscommented, Apr 15, 2020

@bulby97 nope. Still not supporting Android 4.x versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using window.ReactNativeWebView on Android KitKat returns ...
ReactNativeWebView is an empty object: {} instead of an object with postMessage. That works for all versions greater than 4.4. I've also tried ......
Read more >
Android Javascript Interface empty object in webview
In The JS file, or via the console if I'm inspecting the webview via chrome if I call Android or window.Android i get...
Read more >
WebSettings - Android Developers
These default settings will be returned from any getter call. A WebSettings object obtained from WebView#getSettings() is tied to the life of the...
Read more >
WebView - React Native
You can use this component to navigate back and forth in the web view's history and configure various properties for the web content....
Read more >
@expo/config-types | Yarn - Package Manager
Types for the Expo config object app.config.ts . ... Package-specific changes not released in any SDK will be added here just before the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found