android studio 65536

方法数超过65536个,报错:
java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
Error:Execution failed for task ‘:app:packageAllDebugClassesForMultiDex’.

java.util.zip.ZipException: duplicate entry: android/support/multidex/BuildConfig.class

如果出现这个错误,就说明multidex冲突了,去掉不重复的包
Error:Execution failed for task ‘:app:packageAllDebugClassesForMultiDex’.

java.util.zip.ZipException: duplicate entry: android/support/multidex/MultiDex$V14.class

解决方案:

google官方文档:
https://code.google.com/p/android/issues/detail?id=81804
一篇讲述模糊的博文:
http://blog.csdn.net/t12x3456/article/details/40837287

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
        multiDexEnabled true
  }
}

dependencies {
    compile 'com.android.support:multidex:1.0.0'
    androidTestCompile 'com.android.support:multidex-instrumentation:1.0.0'
}


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

你可能感兴趣的:(android studio 65536)