. Advertisement .
..3..
. Advertisement .
..4..
In Android, you can use FileProvider to allow other apps to access files that reside on the external storage. The error “error: package android.support.v4.content does not exist” is thrown if you try to import android.support.v4.content.FileProvider into your Android App. Read on to learn how to fix this.
Why dose this error happen?
FileProvider is considered as a special subclass of ContentProvider
that facilitates secure file sharing associated with an app, it also is created a content://
Uri
for a file instead of a file:///
Uri
. When importing android.support.v4.content.FileProvider into your Android App, You may experience the following error:
error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
The cause:
When you update the android studio IDE to 0.8 to apply with the new android L SDK. To start it, you imported a finished android project that no error return in the last version from the android studio. In version 0.8 i lines like:
import android.support.v4.app.Fragment;
Even you tried some steps such as reinstalling the IDE; removing contents in the idea folder; installing all the SDK’s again – including the support libraries; syncing the gradle; copying the support library into the libs folder manually; building the project again; then adding a new project to test the library. it still return the warning message and you wonder which step or any solution for your problem disappear, click the following part to firgure out. Continue!
How To Fix The Error “error: package android.support.v4.content does not exist import android.support.v4.content.FileProvider”?
Option 1: Upgrade supplier tag in menifest
Simply upgrade the supplier tag in your menifest file.
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
Option 2: Try importing this way
Try importing this way:
import android.support.v4.content.FileProvider;
Instead of:
import androidx.core.content.FileProvider;
Option 3: Include the following line in build.gradle
Simply include the following line in your build.gradle:
compile 'com.android.support:support-v4:26.1.0'
Option 4: Use the following command
npm install jetifier --save
npx jetify
npx cap sync
Conclusion
We hope you found our article on fixing the error “error: package android.support.v4.content does not exist import android.support.v4.content.FileProvider” useful. We understand that dealing with this can be confusing, therefore we hope that our information has assisted you in resolving it. Please leave a comment if you have any further questions or concerns.
Thank you for taking the time to read; we are always delighted anytime one of our pieces can give important information on a topic like this!
have you tried these steps which I copy from another forum and hope it help your issue
Create a library project based on the support library code:
Create a library project and ensure the required JAR files are included in the project’s build path:
You now have a library project for your selected Support Library that you can use with one or more application projects.