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.

error: package androidx.core.content does not existimport androidx.core.content.FileProvider;

See original GitHub issue

Bug 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:

  1. New React Native Project With Cli
  2. yarn add react-native-webview
  3. 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:closed
  • Created 4 years ago
  • Reactions:34
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

29reactions
muhamad-rizkicommented, May 18, 2019

it’s weird, try to remove it first with react-native uninstall react-native-webview, then install it again with react-native install react-native-webview@5.8.1 maybe your local still caching the last installed

16reactions
wenchao1020commented, Aug 14, 2019

add jetifier will fixed it npm install --save-dev jetifier npx jetify npx react-native run-android

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting "error: package androidx.core.content does not exist ...
It says to use the FileProvider class, but when I try to import it, I get the error. "error: package androidx.core.content does not...
Read more >
Error: package androidx.core.content does not exist
I am using Cordova for building an ionic app. I run cmd-. ionic Cordova build android. this is the error that I got....
Read more >
Class androidx.core.content.FileProvider
Set the android:exported attribute to false ; the FileProvider does not need to be public. ... package androidx.core.content; import static org.xmlpull.v1.
Read more >
androidx.core.content - Android Developers
FileProvider is a special subclass of ContentProvider that facilitates secure sharing of files associated with an app by creating a content:// Uri for...
Read more >
core/core/src/main/java/androidx/core/content/ContextCompat ...
package androidx.core.content;. import static android.content.Context. ... This class should not be instantiated, but the constructor must be.
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