Search code examples
androidclassnotfoundexceptionandroid-4.4-kitkat

java.lang.ClassNotFoundException under API Level 19


I have an app, that starts except under API 19 and I get the stacktrace below.

I previously had to add to gradle's build:

defaultConfig {
        multiDexEnabled true

from another similar question I added also the dependency

depenencies {
   ...
   compile 'com.android.support:multidex:1.0.1'
   ...
}

But still the app crashes at start under API19.

Can someone help ?

02-21 16:07:05.043 3348-3348/? E/memtrack: Couldn't load memtrack module (No such file or directory) 02-21 16:07:05.043 3348-3348/? E/android.os.Debug: failed to load memtrack module: -2 02-21 16:07:19.723 3359-3359/? E/memtrack: Couldn't load memtrack module (No such file or directory) 02-21 16:07:19.723 3359-3359/? E/android.os.Debug: failed to load memtrack module: -2 02-21 16:07:19.923 2015-2015/com.google.android.gms E/dalvikvm: Dex cache directory isn't writable: /data/dalvik-cache 02-21 16:07:19.923 2015-2015/com.google.android.gms E/ChimeraModuleLdr: Initialization failed for module apk com.google.android.play.games
                                                                        java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.chimera.GmsModuleInitializer" on path: DexPathList[[zip file "/system/app/PlayGames.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
                                                                            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                            at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
                                                                            at csg.loadClass(:com.google.android.gms@11947030:3)
                                                                            at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
                                                                            at com.google.android.gms.chimera.container.GmsModuleApi.onApkLoaded(:com.google.android.gms@11947030:1)
                                                                            at csm.a(:com.google.android.gms@11947030:88)
                                                                            at csm.a(:com.google.android.gms@11947030:35)
                                                                            at csm.a(:com.google.android.gms@11947030:118)

Solution

  • According to the docs, did you either make you application extend MultiDexApplication or initialize multidex in your application class? Like so:

    Either do this:

    Make application class extent MultiDexApplication

    public class MyApplication extends MultiDexApplication { ... }
    

    Change manifest like so:

    <?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>
    

    Or this

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