IntelliJ 10.5:如何不添加“测试”生成的 .apk 文件中的范围依赖项?
我在 IntelliJ 的 Android 项目中添加了几个依赖项,用于单元测试(JUnit4
、JMock
、SQLite-jdbc
等) 。我在模块依赖项设置中将它们全部定义为“测试”范围,以便仅在运行我的非测试时使用它们,并且它们不会妨碍生产代码。
我的问题是,当生成 .apk 文件时,它基本上忽略了“测试”范围设置,并包含所有不需要的依赖项,这使 .apk 的大小增加了十几 MB。
有没有办法防止这种情况发生?
I've added several dependencies in my Android project in IntelliJ, for unit-tests (JUnit4
, JMock
, SQLite-jdbc
, etc.). I defined all of them as "test" scope in the module dependencies settings, so that they are used only when running my unt-tests and they don't get in the way of the production code.
My problem is that when the .apk file is generated, it basically ignores the "test" scope setting, and includes all the unneeded dependencies, which boost the size of the .apk by a dozen MBs.
Is there a way to prevent this from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 测试可以在设备上运行,因此可能需要测试依赖项才能实际运行它们。如果您在测试中使用的类已作为 Android 平台的一部分在设备上提供,您可以尝试将范围设置为已提供。
Android tests can run on device, therefore test dependencies may be required to actually run them. If classes that you are using in the tests are already available on the device as a part of Android platform, you can try setting the scope to Provided.