且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何解决android 4.4.2错误ClassNotFoundException:没有找到类“com.google.firebase.provider.FirebaseInitProvider”在路径上:DexPathList

更新时间:2022-10-22 19:20:14

Note: If your project is configured for multidex with minSdkVersion 20 or lower, and you deploy to target devices running Android 4.4 (API level 20) or lower, Android Studio disables Instant Run.

When running on versions prior to Android 5.0 (API level 21), using multidex is not enough to work around the linearalloc limit (issue 78035). This limit was increased in Android 4.0 (API level 14), but that did not solve it completely. And on versions lower than Android 4.0, you might reach the linearalloc limit before reaching the DEX index limit. So if you are targeting API levels lower than 14, test thoroughly on those versions of the platform, because your app might have issues at startup or when particular groups of classes are loaded. Code shrinking can reduce or possibly eliminate these issues.

You have too many methods. There can only be 65536 methods for dex.

So, enable multidex as following:

android {    
defaultConfig {
    // Enabling multidex support.
    multiDexEnabled true
}  
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}

create one class like this

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

now in your manifiest file add this

<application
    android:name=".Multi_Dex"
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

to solve this problem s, like described on this link : developer.android.com/studio/build/multidex

or try this my friend for kitkat or lower version

android {
defaultConfig {
    ...
    multiDexEnabled true
}
productFlavors {
    dev {
        // Enable pre-dexing to produce an APK that can be tested on
        // Android 5.0+ without the time-consuming DEX build processes.
        minSdkVersion 21
    }
    prod {
        // The actual minSdkVersion for the production version.
        minSdkVersion 14
    }
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
                                             'proguard-rules.pro'
    }
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}