A Maharaja A Maharaja - 5 months ago 182
Android Question

How to fix android 4.4.2 error ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList


AndroidRuntime: FATAL EXCEPTION: main
Process: com.info.app, PID: 24503
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.info.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-1, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5236)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.access$1600(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.info.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5221)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710) 
at android.app.ActivityThread.access$1600(ActivityThread.java:174) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5593) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 


build.gradle

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
mavenCentral()
maven() {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven { url 'https://maven.fabric.io/public' }

}

android {
dexOptions {
javaMaxHeapSize "4g"
}

compileSdkVersion 25
buildToolsVersion '25.0.1'
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
applicationId "com.info.app"
minSdkVersion 17
targetSdkVersion 25
versionCode 16
versionName "1.0.12"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
signingConfig signingConfigs.config
}
debug {
debuggable true
signingConfig signingConfigs.config
}
}

packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':CustomBrowser-release')
compile project(':PayU-release')
compile project(':sdkui')

compile('com.github.worker8:tourguide:1.0.17-SNAPSHOT@aar') {
transitive = true
}
compile('com.twitter.sdk.android:twitter:2.3.2@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile 'com.intuit.sdp:sdp-android:1.0.4'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:cardview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.google.android.gms:play-services:10.2.4'
compile 'com.facebook.android:facebook-android-sdk:4.15.0'
compile 'com.google.firebase:firebase-messaging:10.2.4'
compile 'com.nononsenseapps:filepicker:3.1.0'
compile 'com.ufreedom.uikit:FloatingViewLib:1.0.2'
compile 'com.github.paolorotolo:appintro:4.1.0'
compile 'com.google.firebase:firebase-crash:10.2.4'
compile 'com.google.firebase:firebase-appindexing:10.2.4'
compile 'com.stripe:stripe-android:3.1.1'
compile 'com.braintreepayments:card-form:3.0.5'
compile 'com.daimajia.numberprogressbar:library:1.4@aar'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'


MyApplication.java

public class MyApplication extends Application {

@Override
public void onCreate() {
MultiDex.install(getApplicationContext());
super.onCreate();


androidmanifest.xml

<application
android:name=".MyApplication"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="@style/MyMaterialTheme">


only app unfortunately stopped android below 4.4
Latest log file

06-17 16:50:36.955 586-586/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.

06-17 16:50:37.005 586-586/? I/SELinux: Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_GT-I9192_4.4.2_0055


06-17 16:50:37.005 586-586/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
06-17 16:50:37.005 586-586/? E/dalvikvm: >>>>> Normal User
06-17 16:50:37.005 586-586/? E/dalvikvm: >>>>> com.info.app [ userId:0 | appId:10286 ]
06-17 16:50:37.005 586-586/? D/dalvikvm: Late-enabling CheckJNI
06-17 16:50:37.415 586-586/com.info.app D/AndroidRuntime: Shutting down VM
06-17 16:50:37.415 586-586/com.info.app W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41ea2da0)
06-17 16:50:37.415 586-586/com.info.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.info.app, PID: 586
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.info.app-3.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-3, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5236)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.access$1600(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.info.app-3.apk"],nativeLibraryDirectories=[/data/app-lib/com.info.app-3, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:5221)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710) 
at android.app.ActivityThread.access$1600(ActivityThread.java:174) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5593) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 

Answer Source

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'
}