美文网首页
android开发 The number of method

android开发 The number of method

作者: 长耳 | 来源:发表于2017-09-23 16:18 被阅读0次

    在打包的时候出现: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

    也就是说你的.dex文件 的大小大于64K,这个问题的出现是因为google限制Android app 方法数64000 (我也不知道哪里说的 他们都这样说)

    解决方法:

    1.Launch App的 build.gradle中添加引用 实现多dex打包

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

    2.builde.gradle 中 

    android{

         defultConfig{

               multiDexEnabled true

          }

     }

    3.在自己自定义的Application集成MultiDexApplication

    并重写方法

    @Override

    protected voidattachBaseContext(Context base) {

    super.attachBaseContext(base);

    MultiDex.install(base);//方法过多

    }

    配置AndroidManifest中<application> 标签name属性 为自己定义的application

    tips:

    1.查看'com.ceabie.dexnkife' 用法 具体详情用法自行百度

    a.在主的build.gradle 中添加   classpath'com.ceabie.dextools:gradle-dexknife-plugin:1.5.9'

    b.在app中配置 apply plugin:'com.ceabie.dexnkife'

    c.在app一级子目录创建dexknife.txt文件

    2.介绍一个插件:Android Methods Count 

    有了该插件就可以非常方便看到引入的类库的方法数量,可以用于权衡是否值得引入该库。

    github地址:https://plugins.jetbrains.com/plugin/8076-android-methods-count

    安装流程:Android studio : file-->setting-->plugins-->Browse Repositories(界面底部第二个按钮)-->搜索"Android Methods Count"

    -->install-->Restart Android Studio

    卸载流程:Android studio : file-->setting-->plugins-->搜索"Android Methods Count"-->Uninstall-->Restart Android Studio

    tips:百度 dexnkife 插件

    愿美好常伴君身

    相关文章

      网友评论

          本文标题:android开发 The number of method

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