2

I am trying to debug my android application but unfortunately it gives exception : Java.Lang.RuntimeException: 'Unable to get provider android.support.v4.content.fileprovider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.fileprovider" on path: DexPathList[[zip file "/data/app/com.companyname.finalproject_pu-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.finalproject_pu-1/lib/arm64, /data/app/com.companyname.finalproject_pu-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]' I have tried :

  1. Bin / Object delete
  2. Build Rebuild
  3. I have added a code in manifest file :
    <provider
   android:name="android.support.v4.content.fileprovider"
   android:authorities="com.companyname.finalproject_pu.fileprovider"
   android:grantUriPermissions="true"
   android:exported="false">

   <meta-data
      android:name="android.support.FILE_PROVIDER_PATHS"
      android:resource="@xml/file_paths" />
</provider>

my original code of provider is:

<provider android:name="xamarin.essentials.fileProvider" android:authorities="com.companyname.finalproject_pu.fileprovider" 
android:exported="false" 
android:grantUriPermissions="true">
      <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
      
      <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    </provider> 
Nabeel Ali
  • 74
  • 8

1 Answers1

3

First,make sure your <provider> content is inside <Appliacation> tag.

<application ...>
  <provider
    android:authorities="com.companyname.finalproject_pu.fileprovider"
    android:name="android.support.v4.content.FileProvider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
  </provider>
</application>

Second,if it still throws the error,perhaps you are still using the old package,try to change android.support.v4.FileProvider to androidx.core.content.FileProvider.

You can find the complete list of androidx migrations here :https://developer.android.com/jetpack/androidx/migrate/class-mappings.

Leo Zhu
  • 15,726
  • 1
  • 7
  • 23