class not found in android Kitkat

If you have migrated to AndroidX you have to change the name in AndroidManifest.xml to androidx.core.content.FileProvider

That was the crash in my case.

I have the same question, and this documentation solve my problem. multidex

before android 5.0, you must use follow ways to multidex:

android {
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 28
    multiDexEnabled true

dependencies {
  compile ''

and then modify application, select any one of three ways:

if you not implement application:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
            android:name="" >

if you have custom application, you can modify like this:

public class MyApplication extends MultiDexApplication { ... }

if you have replace base application, you can modify like this:

public class MyApplication extends SomeOtherApplication {
   protected void attachBaseContext(Context base) {

Hope this can solve you problem.

in my project when set "multiDexEnabled" false, error fixed. go to manifest and add

android {

defaultConfig {
    multiDexEnabled false

hope this is helpful

Chandravir Singh JAAT

Just delete the intermediates folder.

Click here for structure

After thorough reading of Android Multidex documentation, I found that there is one configuration we generally miss which causes java.lang.NoClassDefFoundError. If you have done regular multidex configuration for 65K reference limit and and still unable to get rid of java.lang.NoClassDefFoundError then you must follow these steps.

  1. Create a file called multidex-config.txt at app level(same directory as the build.gradle file)
  2. Add following line (the absolute class name for which you are getting exception)
  3. Modify your build.gradle as follow

    android {
        buildTypes {
            release {
                multiDexKeepFile file('multidex-config.txt')

    Note : You can add it for specific build type or both by declaring it in defaultConfig.

What happens when you build a multidex enabled app :

The Android build tools construct a primary DEX file (classes.dex) and supporting DEX files (classes2.dex, classes3.dex, and so on) as needed. The build system then packages all DEX files into your APK.

At runtime, the multidex APIs use a special class loader to search all of the available DEX files for your methods (instead of searching only in the main classes.dex file).

Cause of Exception :

When building each DEX file for a multidex app, the build tools perform complex decision-making to determine which classes are needed in the primary DEX file so that your app can start successfully. If any class that's required during startup is not provided in the primary DEX file, then your app crashes with the error java.lang.NoClassDefFoundError.

This shouldn't happen for code that's accessed directly from your app code because the build tools recognize those code paths, but it can happen when the code paths are less visible such as when a library you use has complex dependencies. For example, if the code uses introspection or invocation of Java methods from native code, then those classes might not be recognized as required in the primary DEX file.

So if you receive java.lang.NoClassDefFoundError, then you must manually specify these additional classes as required in the primary DEX file by declaring them with the multiDexKeepFile (shown above) or the multiDexKeepProguard (refer documentation) property in your build type. If a class is matched in either the multiDexKeepFile or the multiDexKeepProguard file, then that class is added to the primary DEX file.

For complete documentation on multidex refer

Click to AndroidManifest.xml look at the bottom of the files page you gonna see "Text" and "Merged Manifes" then click to "Merged Manifest" -> Search for "" then change it with "androidx.core.content.FileProvider"

Thats it, exact solution.

The following code works for me (I've migrated to AndroidX):

            android:resource="@xml/provider_paths" />

FileProvider was introduced with Android API Level 22 which is Lollipop, that is why you did not face the ClassNotFoundException when testing on a Lollipop device. Android Kitkat does not have the FileProvider class and hence you are facing the exception. If you are looking to access files this post should help you out