multiDexKeepFile无法正常工作 [英] multiDexKeepFile not working

查看:473
本文介绍了multiDexKeepFile无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在构建multidex应用程序时遇到了问题.在应用程序启动期间,我们不断收到不同的 java.lang.NoClassDefFoundError 错误.

We are having problems in building our multidex App. We keep receiving different java.lang.NoClassDefFoundError erros during the application boot.

我们注意到它们很可能与multidex问题有关.由于启动应用程序所需的类必须存在于主DEX文件中,并且它们未包含在 classes.dex 中.我们执行了 https://developer.android.com/studio/build中描述的步骤/multidex.html#keep 但是我们在 multidex-config.txt 甚至甚至在 multidex-config.pro 中指定的类都没有放置在主dex文件中( classes.dex ).

We noticed that they are very likely related to the multidex issues. As the required classes for booting the App must be present in the primary DEX file and they are not being included in the classes.dex. We performed the steps described in https://developer.android.com/studio/build/multidex.html#keep but the classes we specify in the multidex-config.txt, or even in the multidex-config.pro are not being placed in the primary dex file (classes.dex).

你们有使用 multiDexKeepFile 或multiDexKeepProguard的经验吗?真的有效吗?是否有任何技巧可以使其工作并将文件放置在 classes.dex 中?

Do you guys have experience using the multiDexKeepFile or the multiDexKeepProguard? Does it really work? Is there any trick to make it work and place the files in the classes.dex?

推荐答案

尝试更新gradle插件.我已经看到,在 2.2.0 中,配置被完全忽略.当我更新到 2.3.3 时,它开始遵守我设置的规则.

Try updating your gradle plugin. I've seen that in 2.2.0 the configuration is ignored entirely. When I updated to 2.3.3 it started respecting the rules I set.

示例:

classpath com.android.tools.build:gradle:2.3.3

在我的默认配置中,我进行了以下设置:

And in my default config I have this set:

    multiDexEnabled true
    multiDexKeepProguard file('proguard.multidex.config')

此外,您可能还必须做一个干净的构建,才能反映出更改.

Also you may have to do a clean build before the changes are reflected.

这篇关于multiDexKeepFile无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆