Android FileProvider class not found in release builds

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>

B. If you do extend your Application class and but can change the base class:

public class MyApplication extends MultiDexApplication { ... }

C. If you do extend your Application class and cannot change the base class:

  public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

For more info:

https://developer.android.com/studio/build/multidex.html#mdex-gradle

Leave a Comment