error: package androidx.core.content does not existimport androidx.core.content.FileProvider;
See original GitHub issueBug description:
New React Native Project. “react-native-webview”: “6.0.1”
Error when build (react-native run-android)
Task :react-native-webview:compileDebugJavaWithJavac (omited)\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewFileProvider.java:3: error: package androidx.core.content does not exist import androidx.core.content.FileProvider;
To Reproduce:
- New React Native Project With Cli
- yarn add react-native-webview
- react-native link react-native-webview
App.json
import React, {Component} from 'react'
import {StyleSheet} from 'react-native'
import { WebView } from 'react-native-webview'
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<WebView source={{uri: 'https://www.google.com'}} />
);
}
}
Complete Error:
info Starting JS server… info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)…
Configure project :react-native-webview :react-native-webview:reactNativeAndroidRoot C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native\android
Task :react-native-webview:compileDebugJavaWithJavac C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewFileProvider.java:3: error: package androidx.core.content does not exist import androidx.core.content.FileProvider; ^ C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewFileProvider.java:10: error: cannot find symbol public class RNCWebViewFileProvider extends FileProvider { ^ symbol: class FileProvider C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:14: error: cannot find symbol import androidx.annotation.RequiresApi; ^ symbol: class RequiresApi location: package androidx.annotation C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:15: error: package androidx.core.content does not exist import androidx.core.content.ContextCompat; ^ C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:16: error: package androidx.core.content does not exist import androidx.core.content.FileProvider; ^ C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:178: error: cannot find symbol @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) ^ symbol: class RequiresApi location: class RNCWebViewModule C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:224: error: cannot find symbol if (ContextCompat.checkSelfPermission(getCurrentActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ^ symbol: variable ContextCompat location: class RNCWebViewModule C:\GIT\Ragnarok\ragnarok-app-webview\node_modules\react-native-webview\android\src\main\java\com\reactnativecommunity\webview\RNCWebViewModule.java:352: error: cannot find symbol return FileProvider.getUriForFile(getReactApplicationContext(), packageName + “.fileprovider”, capturedFile); ^ symbol: variable FileProvider location: class RNCWebViewModule Note: C:\GIT\Ragnarok\ragnarok-app-webview\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:\GIT\Ragnarok\ragnarok-app-webview\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. 8 errors
Task :react-native-webview:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ‘:react-native-webview:compileDebugJavaWithJavac’.
Compilation failed; see the compiler error output for details.
Environment:
- OS: Windows
- OS version: 10
- react-native version: 0.59.8
- react-native-webview version: 6.0.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:34
- Comments:22 (1 by maintainers)
Top GitHub Comments
it’s weird, try to remove it first with
react-native uninstall react-native-webview
, then install it again withreact-native install react-native-webview@5.8.1
maybe your local still caching the last installedadd jetifier will fixed it npm install --save-dev jetifier npx jetify npx react-native run-android