Reputation: 10967
I am trying to use https://github.com/react-native-community/react-native-webview.
I get this error when I try and react-native run-android
, any ideas how I can use webview?
\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:54: error: package com.reactnativecommunity.webview.events does not exist
Using:
react-native-cli: 2.0.1 react-native: 0.57.1
error in full:
Task :react-native-webview:compileDebugJavaWithJavac C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:54: error: package com.reactnativecommunity.webview.events does not exist import com.reactnativecommunity.webview.events.TopLoadingErrorEvent; ^ C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:55: error: package com.reactnativecommunity.webview.events does not exist import com.reactnativecommunity.webview.events.TopLoadingFinishEvent; ^ C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:56: error: package com.reactnativecommunity.webview.events does not exist import com.reactnativecommunity.webview.events.TopLoadingProgressEvent; ^ C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:57: error: package com.reactnativecommunity.webview.events does not exist import com.reactnativecommunity.webview.events.TopLoadingStartEvent; ^ C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:58: error: package com.reactnativecommunity.webview.events does not exist import com.reactnativecommunity.webview.events.TopMessageEvent; ^ C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:59: error: package com.reactnativecommunity.webview.events does not exist import com.reactnativecommunity.webview.events.TopShouldStartLoadWithRequestEvent; ^ C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:455: error: cannot find symbol export.put(TopLoadingProgressEvent.EVENT_NAME, MapBuilder.of("registrationName", "onLoadingProgress")); ^ symbol: variable TopLoadingProgressEvent location: class RNCWebViewManager C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:456: error: cannot find symbol export.put(TopShouldStartLoadWithRequestEvent.EVENT_NAME, MapBuilder.of("registrationName", "onShouldStartLoadWithRequest")); ^ symbol: variable TopShouldStartLoadWithRequestEvent location: class RNCWebViewManager C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:457: error: method getJSEventName in enum ScrollEventType cannot be applied to given types; export.put(ScrollEventType.getJSEventName(ScrollEventType.SCROLL), MapBuilder.of("registrationName", "onScroll")); ^ required: no arguments found: ScrollEventType reason: actual and formal argument lists differ in length C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:732: error: cannot find symbol new TopLoadingProgressEvent( ^ symbol: class TopLoadingProgressEvent location: class RNCWebChromeClient C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:617: error: cannot find symbol new TopLoadingStartEvent( ^ symbol: class TopLoadingStartEvent location: class RNCWebViewClient C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:626: error: cannot find symbol new TopShouldStartLoadWithRequestEvent( ^ symbol: class TopShouldStartLoadWithRequestEvent location: class RNCWebViewClient C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:659: error: cannot find symbol new TopLoadingErrorEvent(webView.getId(), eventData)); ^ symbol: class TopLoadingErrorEvent location: class RNCWebViewClient C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:665: error: cannot find symbol new TopLoadingFinishEvent( ^ symbol: class TopLoadingFinishEvent location: class RNCWebViewClient C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java:901: error: cannot find symbol dispatchEvent(this, new TopMessageEvent(this.getId(), message)); ^ symbol: class TopMessageEvent location: class RNCWebView Note: C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\Matt\sites\tcapp\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewManager.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 15 errors
Task :react-native-webview:compileDebugJavaWithJavac FAILED
Upvotes: 2
Views: 6932
Reputation: 975
click node_modules folder
delete react-native-webview folder
install latest one npm i react-native-webview
Upvotes: 0
Reputation: 1008
This issue happened to me
i had these versions of react-native and 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",
...
}
Everything was fine for my previous version of project nothing happned with this version.
After updating android-studio and upgrade the gradle, i freshly build and run the same project (after i clone the same project from my github repo.). This issue occured, then i put and checked each new version (above 5.12.1) of react-native-webview
. Finally, it matched, fixed the error and successfully build the app with this version.
"react-native-webview": "^7.5.2"
{
"react": "16.8.3",
"react-native": "0.59.9",
"react-native-webview": "^7.5.2",
...
}
Upvotes: 1