20

Receiving this error on Android 4.4 device when starting my app. App immediately crashes. However I don't have this error on Android 5.1 device. Any clue?

10-15 22:35:06.306 14072-14072/com D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0000 10-15 22:35:06.306 14072-14072/com D/AndroidRuntime﹕ Shutting down VM 10-15 22:35:06.306 14072-14072/com W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4304b160) 10-15 22:35:06.306 14072-14072/com E/AndroidRuntime﹕ FATAL EXCEPTION: main Process:com., PID: 14072 java.lang.NoClassDefFoundError: com.google.android.gms.internal.zzmp at com.google.android.gms.measurement.internal.zzz.zzj(Unknown Source) at com.google.android.gms.measurement.internal.zzv.(Unknown Source) at com.google.android.gms.measurement.internal.zzz.zzAq(Unknown Source) at com.google.android.gms.measurement.internal.zzv.zzaL(Unknown Source) at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source) at android.content.ContentProvider.attachInfo(ContentProvider.java:1591) at android.content.ContentProvider.attachInfo(ContentProvider.java:1562) at android.app.ActivityThread.installProvider(ActivityThread.java:4830) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4425) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4365) at android.app.ActivityThread.access$1500(ActivityThread.java:138) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:149) at android.app.ActivityThread.main(ActivityThread.java:5061) 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:787) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603) at dalvik.system.NativeStart.main(Native Method)

MobileMon
  • 8,341
  • 5
  • 56
  • 75
  • 4
    ATTENTION To anybody reading this though! The real problem was that I was using the ENTIRE google play services framework which was forcing me into multi dex. Avoid multi dex if you can because it slows builds down builds. Only bring in what you need from google play services. So instead of putting "compile 'com.google.android.gms:play-services:8.1.0'", put "compile 'com.google.android.gms:play-services-location:8.1.0'" for example. – MobileMon Oct 19 '15 at 20:00
  • Thank you so much for clarifying this! Resolved my issues. – Nicky Hajal Jun 15 '16 at 19:23
  • http://stackoverflow.com/questions/34592849/java-lang-noclassdeffounderror-com-google-android-gms-common-internal-zzd – Shirish Herwade Oct 03 '16 at 11:32
  • Getting this issue on Unity. Any fix for that? – Jawad Amjad Aug 30 '17 at 10:56

3 Answers3

38

needed to add this in class that extends Application:

 @Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

EDIT: I noticed this answer is becoming more popular so please note my comment on the question:

"ATTENTION To anybody reading this though! The real problem was that I was using the ENTIRE google play services framework which was forcing me into multi dex. Avoid multi dex if you can because it slows down builds. Only bring in what you need from google play services. So instead of putting "compile 'com.google.android.gms:play-services:8.1.0'", put "compile 'com.google.android.gms:play-services-location:8.1.0'" for example."

MobileMon
  • 8,341
  • 5
  • 56
  • 75
  • 3
    thanks! worked perfectly and your tip on compiling only part of the play service is great!! thanks again! – ᴛʜᴇᴘᴀᴛᴇʟ Oct 23 '15 at 16:12
  • What does the calss extending application? You mean developers have to copy and paste that method all the classes in the project? –  Dec 08 '15 at 09:54
  • Most Android apps have a need to extend Application, see here: http://developer.android.com/reference/android/app/Application.html – MobileMon Dec 08 '15 at 13:51
  • 1
    Why is `MultiDex` class not found? What dependency am I missing? – Aron Lorincz Dec 12 '15 at 12:54
  • What if none of my classes extends Application? – Jonas Feb 20 '16 at 21:27
  • 3
    Then make a class that does – MobileMon Feb 22 '16 at 13:07
  • Does it mean that for Android 4.x, or API Level 20 or below, it is not sufficient to use this in the dependencies?: "compile 'com.android.support:multidex:1.0.0'". Why is it necessary to include the method provided in this answer? I thought the MultiDEX 1.0.0 dependency would be taking care of that. – Jaime Montoya Jun 14 '17 at 00:58
  • I was reading the documentation at https://developer.android.com/reference/android/support/multidex/MultiDex.html and I found this paragraph: "This library provides compatibility for platforms with API level 4 through 20. This library does nothing on newer versions of the platform which provide built-in support for secondary dex files." So the code provided in this answer would be fixing the compatibility issue for API Level 4 through 20, which includes all Android 4.x versions, and at the same time it would not affect at all versions with Android 5.x and above, correct? – Jaime Montoya Jun 14 '17 at 15:59
2

For those who have already activated MultiDex and still get this exception, it's just a stupid Android Studio / Gradle issue.

Try cleaning project, toggling Instant Run in settings, and rebuilding the project.

Iman Akbari
  • 2,167
  • 26
  • 31
0

I had the error and i resolved it by updating the gms play-service to the latest version.

kayleb
  • 19
  • 3