美文网首页Android知识
解决“com.android.dex.DexIndexOverf

解决“com.android.dex.DexIndexOverf

作者: 爱因私谈 | 来源:发表于2017-09-24 12:15 被阅读0次
    1. 谷歌官方已经给出了相关的文档,参照网上搜索的资料,首先,我的问题是:
    Error:Execution failed for task ':duchazhushou:dexRelease'.
    > com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        C:\Users\jeff\AppData\Local\Android\sdk\android-sdk\build-tools\21.1.1\dx.bat --dex --output D:\dev\android\Duchazhushou_TDT\duchazhushou\build\intermediates\dex\release --input-list=D:\dev\android\Duchazhushou_TDT\duchazhushou\build\intermediates\tmp\dex\release\inputList.txt
    Error Code:
    Output:
        UNEXPECTED TOP-LEVEL EXCEPTION:
        com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
            at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
            at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
            at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
            at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
            at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
            at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
            at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
            at com.android.dx.command.dexer.Main.run(Main.java:245)
            at com.android.dx.command.dexer.Main.main(Main.java:214)
            at com.android.dx.command.Main.main(Main.java:106)
    
    1. 在项目的build.gradle文件的dependencies 节中添加分包设置:
    dependencies { 
    ... 
       compile 'com.android.support:multidex:' 
       ... 
    }
    
    1. 通过在defaultConfig节中设置multiDexEnabled标签为true,开启multi-dexing支持:
    defaultConfig { 
       ... 
    multiDexEnabled true 
    ... 
    }
    
    1. Application继承android.support.multidex.MultiDexApplication,或直接在AndroidManifest.xml文件的Application声明中添加:
    android:name="android.support.multidex.MultiDexApplication"
    
    1. 重新build。

    参考来源

    相关文章

      网友评论

        本文标题:解决“com.android.dex.DexIndexOverf

        本文链接:https://www.haomeiwen.com/subject/tjjkextx.html