Non-existence of com.reactnativecommunity.webview.events causing React Native WebView Error

I’m encountering an error while attempting to utilize webview. Any suggestions on how to proceed? The error message I’m receiving is as follows:
node_modulesreact-native-webviewandroidsrcmainjavacomreactnativecommunitywebviewRNCWebViewManager.java:54: error: package com.reactnativecommunity.webview.events does not exist.
The versions I’m currently using are:
– react-native-cli: 2.0.1
– react-native: 0.57.1
This issue only occurred with this specific version, as the previous version did not produce any errors. Other pertinent information includes:
– Gradle version: 4.10.1
– “react-native”: “^0.59.9”
– “@react-native-community/viewpager”: “^1.1.7”
There are two potential solutions to this issue:
Solution 1:
– Install the ‘jetifier’ package by running ‘npm i jetifier’
– Run ‘npx jetify’
– If the issue persists, set the following in the default config of the module level build.gradle file: multiDexEnabled true
Solution 2:
– Install the ‘@jumpn/react-native-jetifier’ package
– Run the command
– react-native run-android
I’m unsure of what changes may have led to this error, but I’m currently unable to run my app on android devices.


Question:

I am attempting to utilize the platform available at https://github.com/ with the specific community and resources provided.

When attempting to utilize webview, I encounter an error with

react-native run-android

. Are there any suggestions for resolving this issue?

Line 54 of RNCWebViewManager.java in node_modulesreact-native-webviewandroidsrcmainjavacomreactnativecommunitywebview indicates an error wherein the package com.reactnativecommunity.webview.events is not found.

Using:

The versions of react-native-cli and react-native being used are 2.0.1 and 0.57.1 respectively.

error in full:

While attempting to compileDebugJavaWithJavac for react-
native-webview
task, an error occurred in RNCWebViewManager.java file located at C:UsersMattsitestcappnode_modulesreact-native-webviewandroidsrcmainjavacomreactnativecommunitywebview. The error was due to the absence of packages such as TopLoadingErrorEvent, TopLoadingFinishEvent, TopLoadingProgressEvent, TopLoadingStartEvent in the com.reactnativecommunity.webview.events.

The error message displayed on line 59 of RNCWebViewManager.java states that the package com.reactnativecommunity.webview.events does not exist. The export.put method on line 456 cannot find the variable TopShouldStartLoadWithRequestEvent. The ScrollEventType enum’s getJSEventName method on line 457 cannot be applied to given types. On line 3, the TopMessageEvent package is imported. On line 74, the export.put method for TopLoadingProgressEvent uses MapBuilder to register the event name as “onLoadingProgress”.

The ScrollEventType argument is missing, causing a difference in the length of the actual and formal argument lists, which results in errors. The TopLoadingProgressEvent, TopLoadingStartEvent, TopShouldStartLoadWithRequestEvent, and TopLoadingErrorEvent classes cannot be found, leading to errors in the RNCWebViewManager.java file located in the C:UsersMattsitestcappnode_modulesreact-native-webviewandroidsrcmainjavacomreactnativecommunitywebview directory.

The Java compilation with Javac failed for the react-native-webview task in debug mode.


Solution:

This issue happened to me

I had multiple versions of React-Native, including the

react-native-webview

version.

 "react-native-webview": "^5.12.1"
{
   "react": "16.8.3",
   "react-native": "0.59.9",
   "react-native-webview": "^5.12.1",
   ...
}

The earlier version of my project was running smoothly, however, there were no significant updates in the current version.

Upon updating android-studio and gradle, I cloned a project from my github repo and performed a fresh build and run. This led to the occurrence of an issue, which I resolved by testing each new version (above 5.12.1) of

react-native-webview

. Once I found the version that matched and fixed the error, I was able to successfully build the app.

"react-native-webview": "^7.5.2"
{
   "react": "16.8.3",
   "react-native": "0.59.9",
   "react-native-webview": "^7.5.2",
   ...
}

Frequently Asked Questions