代码改变世界

DexIndexOverflowException: Cannot merge new index 66080 into a non-jumbo instruction!

2015-12-24 11:33  硕硕  阅读(438)  评论(0编辑  收藏  举报

问题

该问题是方法数超过了65536(DEX 64K problem),无法编译成单个dex文件。

解决方案

谷歌官方给出的解决方案


android {

    compileSdkVersion 21

    buildToolsVersion "21.1.0"



    defaultConfig {

        ...

        minSdkVersion 14

        targetSdkVersion 21

        ...



        // Enabling multidex support.

        multiDexEnabled true

    }

    ...

}



dependencies {

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

}

没有自定义Application


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

</manifest>

自定义Appication


public class MyApplication extends android.support.multidex.MultiDexApplication{

        ...

}