Android studio环境下: The number of method references in a .dex file cannot exceed 64K. 解决方法

Android studio环境下: The number of method references in a .dex file cannot exceed 64K. 解决方法

错误日志:

Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

解决方法分两步:

一. 在app 的 build.gradle 中:

(1) 在dependencies 中添加 compile 'com.android.support:multidex:1.0.0'

(2) 在 defaultConfig 中添加 multiDexEnabled true

具体如下:


dependencies {

    //1. 在最外层的dependencies(dependencies可能有多个, 确保是与下面的android 同级的 dependencies中) 里添加下面这句
    compile 'com.android.support:multidex:1.0.0'

}

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'

    defaultConfig {
    
        //2. 在defaultConfig中添加 multiDexEnabled true
        multiDexEnabled true
        
        targetSdkVersion 26
        applicationId 'com.feihong.xiongchumo'
    }

}

二. 在AndroidManifest.xml 中的 application 标签中添加 android:name="android.support.multidex.MultiDexApplication"

具体代码:

  
  
    
    
        
        ...
    
    
    

你可能感兴趣的:(Android studio环境下: The number of method references in a .dex file cannot exceed 64K. 解决方法)