Android FileProvider class not found in release builds

didn t find class android support v4 content fileprovider android
android fileprovider external storage
missing android support file_provider_paths meta-data
unable to get provider com imagepicker fileprovider
error: package android support multidex does not exist
unresolved class fileprovider
runtimeexception unable to get provider androidx core content fileprovider
androidx support library

I'm using a FileProvider to get photos from the device. The implementation works just fine in debug builds (minifyEnabled false) but when I'm building the release build (minifyEnabled true) I get an error:

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.package.name-2/base.apk"],
nativeLibraryDirectories=[/data/app/om.package.name-2/lib/arm, /vendor/lib, /system/lib]]

So I guess this has someting to do with the proguard setup

I have

compile 'com.android.support:support-v13:23.1.1'

which is a superset of v4 in my gradle file and

minSdkVersion 21
targetSdkVersion 23

and

-keep class android.support.v4.app.** { *; }
-keep class android.support.v4.content.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep interface android.support.v4.content.** { *; }
-keep class * extends android.content.ContentProvider

in my proguard-rules.pro file

I have tested with both Android 5 and 6 and same thing happens. Any suggestion would be usefull, thanks in advance.

I was using androidx library and getting the same error. So, in AndroidManifest.xml, I changed this line:

android:name="android.support.v4.content.FileProvider"

to this:

android:name="androidx.core.content.FileProvider"

proguard, I am using FileProvider in my app. As usual FileProvider class not found in android Kitkat android { buildTypes { release { multiDexKeepFile file('multidex-​config.txt') . The Android build tools construct a primary DEX file (classes.dex) and  * Resgen * Permissions may need to be checked to control functionality * The Android FileProvider now can detect permissions - internal / external storage can be controlled - KitKat+ does not require the permissions - corrected the FileProvider resource xml * Added support for email attachments - support for a string path and native file types

The following worked for me:

In your module build.gradle file:

defaultConfig {
...
multiDexEnabled true
...

}

Then:

dependencies {
...
compile 'com.android.support:multidex:1.0.2'
...

}

And finally, ensure that your application class has one of the following:

A. If you do not extend your application class:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

android.support.v4.content.FileProvider class not found in android , i'm using fileprovider photos device. implementation works fine in debug builds (​minifyenabled false) when i'm building release build  @matt-oakes Nope, none of my dependencies is using AndroidX. I just had in my build.gradle Google Services with '+' version, which means the last one. 17 June Google announced new major release which broke my app.

After a couple of hours of more googling around I've ended up updating gradle and google services to

dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
    classpath 'com.google.gms:google-services:1.5.0'
}

previously the version ware

    classpath 'com.android.tools.build:gradle:1.3.0'
    classpath 'com.google.gms:google-services:1.5.0-beta2'

I guess there needs to be something with the google-services library

Recent Support Library Revisions, android { buildTypes { release { multiDexKeepFile file('multidex-config.txt') } } } Note : You can add it for specific build type or both by declaring it in defaultConfig​  When an app wants to access a file shared by another app, the requesting app (the client) usually sends a request to the app sharing the files (the server).

Gradle tips and recipes, This is the stable release of Support Library 28.0.0 and is suitable for use in production. which throw an IllegalArgumentException when the target cannot be found. FileProvider now supports getExternalMediaDirs() on API 21 and higher does not clear its Loaders in onCleared; Class file for android.arch.​lifecycle. Instrumented unit tests are tests that run on physical devices and emulators, and they can take advantage of the Android framework APIs and supporting APIs, such as AndroidX Test. Instrumented tests provide more fidelity than local unit tests, but they run much more slowly.

Class androidx.core.content.FileProvider, If you want to learn about ways to make your builds faster, read Optimize Your Build This block encapsulates custom properties and makes them available to all Specifies a list of screen densities Gradle should not create APKs for. release {} } // Specifies the flavor dimensions you want to use. The order in which you In Android, build-name is used as versionName while build-number used as versionCode. For more information, see Version your app in the Android documentation. After updating the version number in the pubspec file, run flutter pub get from the top of the project, or use the Pub get button in your IDE.

ClassNotFoundException: Didn't find class "android.support.v4 , These permissions are available to the client app for as long as the stack for a Set the android:exported attribute to false ; the FileProvider does not need to be public. encodedPath(path).build(); } @Override public File getFileForUri(Uri uri)​  Open "AndroidManifest.template.xml" inside the folder of your project and set android:minSdkVersion="14" and android:targetSdkVersion="26". Set Release mode on Build Configurations. (In Debug mode will not appear the permission box, only in Release mode) <

Comments
  • Have a look at this link. It might help you. https://stackoverflow.com/a/44458490/2054348
  • Check this out stackoverflow.com/a/52813496/5460053
  • Hello @Munier Parker, I have done all these but still getting same issue.
  • What does com.google.gms:google-services have to do with android.support.v4.content.FileProvider?