java.lang.NoClassDefFoundError: com.google.android.gms.common.internal.zzd

早过忘川 提交于 2019-11-28 01:20:50

3 Simple Steps:

Step#1: Multidexing is a new feature and so requires a support library to be compatible with pre-lollipop devices. You need to add the following to your gradle file dependencies:

compile 'com.android.support:multidex:1.0.0'

Step#2: Also enable multidex output in your gradle file:

android {
compileSdkVersion 21
buildToolsVersion "21.1.0"

defaultConfig {
    ...
    minSdkVersion 14
    targetSdkVersion 21
    ...

    // Enabling multidex support.
    multiDexEnabled true
   }
}

Step#3: And then add the multidex support application to your manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
    ...
    android:name="android.support.multidex.MultiDexApplication">
    ...
</application>

Note: If your app already uses(extends) the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex. For more information, see the MultiDexApplication reference documentation.

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

Here are the same instructions for reference: https://developer.android.com/tools/building/multidex.html

After some research and hours of testing I finally realized that android has something called the DEX 64K Methods Limit. In simple words there's a limit you can reach when adding external libraries to your project. When you reaches that limit you might need to use multidex. Personally I decided to reduce the amount of libraries imported as some of them weren't really used or necesary. For further understanding of multidex you should read this,

http://developer.android.com/tools/building/multidex.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!