美文网首页
Building Apps with Over 64K Meth

Building Apps with Over 64K Meth

作者: Ggx的代码之旅 | 来源:发表于2016-05-21 17:42 被阅读16次

今天项目中遇到了一个问题,就是方法超过64K的限制。谷歌了一下 官方早已经给出了解决方案;https://developer.[Android](http://lib.csdn.net/base/15).com/intl/zh-cn/tools/building/multidex.html;感兴趣的可以去阅读一下原文。

  • 解决方案
    • 在app.gradle中添加依赖 compile 'com.android.support:multidex:1.0.0'
    • 在 defaultConfig 中添加 multiDexEnabled true
    • 如果你的项目中没有继承自Application类则只需要在 AndroidManifest.xml 中的application 标签中指定该Application使用
      android:name="android.support.multidex.MultiDexApplication"
      即可;如果你的项目中继承了Application类那么你只需要在该类中重写attachBaseContext()方法即可:
      @Overrideprotected void attachBaseContext(Context base) {
      super.attachBaseContext(base);
      MultiDex.install(this);
      }

相关文章

网友评论

      本文标题:Building Apps with Over 64K Meth

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