[英]android.support.v4.content.FileProvider not found
I am trying to upgrade a working old app to support Android API 26, and one of the thing I need to use is android.support.v4.content.FileProvider - but it was not found.我正在尝试升级一个正常工作的旧应用程序以支持 Android API 26,我需要使用的一件事是 android.support.v4.content.FileProvider - 但它没有找到。
<provider
android:name="android.support.v4.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>
Due to the early Android build, the gradle file seems simple.由于早期的 Android 构建,gradle 文件看起来很简单。 Is it as simple as adding a dependency?
是否像添加依赖项一样简单? I have look around and some suggested adding a multidex which I don't understand.
我环顾四周,有人建议添加一个我不明白的 multidex。 Any help is appreciated, thank you!
任何帮助表示赞赏,谢谢!
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "virtualgs.spaint"
minSdkVersion 22
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
As of AndroidX (the repackaged Android Support Library), the path is androidx.core.content.FileProvider
so the updated provider tag would be:从 AndroidX(重新打包的 Android 支持库)开始,路径为
androidx.core.content.FileProvider
,因此更新后的提供程序标记为:
<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>
Android Support Libraries are now in the androidx.*
package hierarchy. Android 支持库现在位于
androidx.*
包层次结构中。
android.*
is now reserved to the built-in Android System Libraries. android.*
现在保留给内置的 Android 系统库。
Instead of代替
import android.support.v4.content.FileProvider;
Try importing尝试导入
import androidx.core.content.FileProvider;
Using the following commands solved my issue:使用以下命令解决了我的问题:
npm install jetifier --save
npx jetify
npx cap sync
I replaced it with the newer version, which is : androidx.core.content.FileProvider我将其替换为较新的版本,即:androidx.core.content.FileProvider
This worked for me.这对我有用。
将compile 'com.android.support:support-v4:26.1.0'
添加到 app 模块中的build.gradle文件中。
Change to改成
public class FileProvider extends androidx.core.content.FileProvider {
}
for androidx对于 androidx
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
Create your class创建你的班级
import android.support.v4.content.FileProvider;
public class GenericFileProvider extends FileProvider {
}
Add this provider into your AndroidManifest.xml under application tag:将此提供程序添加到您的 AndroidManifest.xml 应用程序标记下:
<provider
android:name=".utilities.GenericFileProvider"
android:authorities="${applicationId}.utilities.GenericFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
Ionic users,离子用户,
ionic cordova rm android
Do that and then rebuild your app.这样做,然后重建您的应用程序。
If you are having this issue with multiple dependencies, you can migrate your entire project to Android X.如果您遇到多个依赖项的问题,您可以将整个项目迁移到 Android X。
To do this, right-click the "app" folder in your project, select "Refactor" and then "Migrate to Android X".为此,请右键单击项目中的“app”文件夹,选择“Refactor”,然后选择“Migrate to Android X”。
Here's a pic:这是一张照片:
Dialog Menu to migrate Android X Project用于迁移 Android X 项目的对话框菜单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.