【发布时间】:2015-08-27 18:54:52
【问题描述】:
我在为某些类运行带有 -encryptclasses 的 DexGuard 时遇到问题。该问题仅在运行 Robolectric 单元测试时发生。我从任何被 DexGuard 混淆和加密的类中得到一个 NullPointerException。如果我关闭 encryptclasses 标志,它可以在 Robolectric 中使用。
该配置也适用于设备和模拟器:在 Android 环境中运行应用程序(在 Dalvik 和 ART 设备和模拟器中测试)运行良好。 Android Instrumentation 测试也有效。只有在通过 Robolectric 运行时,我才会收到 NullPointerException。如果我禁用 DexGuard encryptclasses,一切都在 Robolectric 中正常工作。
DexGuard 正在我所依赖的库中使用。该库已添加到我的 gradle 模块的 libs 文件夹中。
我会将此作为 Robolectric 问题发布,但如果没有 DexGuard 工具的许可,他们可能无法重现。
设置是:
- Android Studio 1.3.2
- Android Gradle 插件 1.3.1
- Android 构建工具版本 23.0.0
- Android compileSdkVersion 22
- Oracle JDK 8
- Ubuntu 15.04 64 位
- DexGuard 版本:5.5.00
【问题讨论】:
标签: java android nullpointerexception robolectric dexguard