gpt4 book ai didi

java - RoboGuice:使用全反射。尝试使用 RoboGuice 注释处理器以获得更好的性能

转载 作者:太空狗 更新时间:2023-10-29 14:56:02 26 4
gpt4 key购买 nike

当我启动我的 RoboGuice android 应用程序时,以下消息出现在日志中:

roboguice.RoboGuice﹕ Using full reflection. Try using RoboGuice annotation processor for better performance.

这是什么意思?

我的所有 Activity (包括我的 MainActivity)都从 RoboGuice 的类扩展而来。也许我遗漏了一些东西,并且有一种方法可以提高我目前没有做的 RoboGuice 性能。

注意:我使用的是 RoboBlender

最佳答案

Roboguice 现已移至版本 4.0.0。这可在 github 上找到,作为分支 rg-4-final。在 gradle 中,您可以将其用作

compile 'org.roboguice:roboguice:4.0.0'
provided 'org.roboguice:roboblender:4.0.0'

我之前在让 Roboblender 工作时遇到过问题,但在 4.0.0 中它就像一个魅力。

虽然有变化。查看 Astroboy 示例以了解如何使用它。您不再扩展 Activity 或 Fragments,而是像这样在每个 Activity 或 Fragments 中注入(inject)成员:

RoboGuice.getInjector(this).injectMembers(this);

他们放弃了 @InjectView@InjectResource,您现在可以使用 Butterknife 注入(inject) View ,并以正常的 Android 方式获取资源。不要忘记在您的应用程序中初始化 Roboguice:

RoboGuice.setupBaseApplicationInjector(this, new MyModule(), new OtherModule());

尽情享受吧!

关于java - RoboGuice:使用全反射。尝试使用 RoboGuice 注释处理器以获得更好的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31359318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com