IntelliJ 10.5:如何不添加“测试”生成的 .apk 文件中的范围依赖项?

发布于 2024-12-15 09:09:54 字数 271 浏览 4 评论 0原文

我在 IntelliJ 的 Android 项目中添加了几个依赖项,用于单元测试(JUnit4JMockSQLite-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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黎夕旧梦 2024-12-22 09:09:54

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文