为了账号安全,请及时绑定邮箱和手机立即绑定

未解决的类“FileProvider”

未解决的类“FileProvider”

慕沐林林 2022-07-14 10:22:09
我正在尝试在 android 设备上拍照并按照本教程进行操作。下面的代码给了我一个错误android.support.v4.content.FileProvider。Android 工作室说Unresolved class 'FileProvider'。我有以下 AndroidManifest.xml 文件:<manifest xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"package="com.example.camera"><uses-permission android:name="android.permission.CAMERA" /><application    android:label="@string/app_name">    <activity android:name=".LandingPageActivity" />    <provider        android:name="android.support.v4.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></application></manifest>我已添加implementation 'com.android.support:support-v4:28.0.0'到我的build.gradle文件中。apply plugin: 'com.android.application'android {    compileSdkVersion 28    defaultConfig {        applicationId "com.example.camera"        minSdkVersion 15        targetSdkVersion 28        versionCode 1        versionName "1.0"        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"        vectorDrawables.useSupportLibrary = true    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'        }    }}dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])    implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'    ...others    implementation 'com.android.support:support-v4:28.0.0'}apply plugin: 'com.google.gms.google-services'我试过这个解决方案没有运气。
查看完整描述

2 回答

?
慕莱坞森

TA贡献1810条经验 获得超4个赞

您正在使用 AndroidX 依赖项(例如您的androidx.appcompat依赖项),因此您需要使用AndroidX FileProvider,它的包名称为androidx.core.content.FileProvider:


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


查看完整回答
反对 回复 2022-07-14
?
守候你守候我

TA贡献1802条经验 获得超10个赞

<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/provider_paths" />


</provider>


查看完整回答
反对 回复 2022-07-14
  • 2 回答
  • 0 关注
  • 241 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号