roboguice

Using Guice to inject dependencies into an Android activity's constructor

让人想犯罪 __ 提交于 2019-12-03 16:23:10
问题 Does anybody know of a way to use Guice to inject dependencies into the constructor of an Activity in Android? It looks like activities normally have only the default constructor so that the platform can easily create a new instance. While it is easy enough to have a singleton to reference the injector and get dependencies that way it is less clean and introduces a bit of static state. Any suggestions? 回答1: I don't know how I missed this! https://github.com/roboguice/roboguice 来源: https:/

Any simple examples using roboguice with fragments in android?

[亡魂溺海] 提交于 2019-12-03 07:20:30
问题 I'm having issues finding a working example of using fragments + RoboGuice. The problem happens when you attempt to add/remove fragments with the Android fragment transaction manager. Once you tell the fragment to inherit from RoboFragment the transaction manager no longer thinks the class is a fragment (because it extends RoboFragment). You can however use RoboGuice's own fragment manager but it also crashes. Is there any examples out there of adding/removing RoboGuice fragments dynamically?

Using Guice to inject dependencies into an Android activity's constructor

两盒软妹~` 提交于 2019-12-03 06:22:38
Does anybody know of a way to use Guice to inject dependencies into the constructor of an Activity in Android? It looks like activities normally have only the default constructor so that the platform can easily create a new instance. While it is easy enough to have a singleton to reference the injector and get dependencies that way it is less clean and introduces a bit of static state. Any suggestions? benstpierre I don't know how I missed this! https://github.com/roboguice/roboguice 来源: https://stackoverflow.com/questions/2525969/using-guice-to-inject-dependencies-into-an-android-activitys

Where is log output written to when using Robolectric + Roboguice?

五迷三道 提交于 2019-12-03 05:25:38
问题 I'm using Robolectric to test Android. I'm running my tests via maven, e.g. mvn -Dtest=LogTest test If I have code that writes to the logs, such as Log.d("TAG", "blah"); or using Roboguice's Ln Ln.d("blah"); I don't see any output in maven's surefire logs (text files). Ideally, I actually want simple log statements to go to the console. I can write to the console by using System.out.println("blah") , but of course I'd rather use the supported logging APIs. So my question is, why am I not

Keep annotated class in Proguard

元气小坏坏 提交于 2019-12-02 22:04:01
I have a bunch of classes that use e.g. an @Singleton annotation like so @Singleton public class ImageCache that I would like to keep. How can I configure a proguard -keep statement so it applies to all classes that have that annotation. Btw in terms of context I need this for an app using Roboguice on Android, which is why I added the tags. Might help others. ProGuard is based on a java-like configuration with wild-cards. It does require fully qualified class names. This should work: -keep @com.google.inject.Singleton public class * First define an annotation public @interface DoNotStrip {}

Any simple examples using roboguice with fragments in android?

情到浓时终转凉″ 提交于 2019-12-02 20:51:21
I'm having issues finding a working example of using fragments + RoboGuice. The problem happens when you attempt to add/remove fragments with the Android fragment transaction manager. Once you tell the fragment to inherit from RoboFragment the transaction manager no longer thinks the class is a fragment (because it extends RoboFragment). You can however use RoboGuice's own fragment manager but it also crashes. Is there any examples out there of adding/removing RoboGuice fragments dynamically? I've recently started using fragments on a new project, and the following is the code I'm using I'm

Where is log output written to when using Robolectric + Roboguice?

佐手、 提交于 2019-12-02 18:43:36
I'm using Robolectric to test Android. I'm running my tests via maven, e.g. mvn -Dtest=LogTest test If I have code that writes to the logs, such as Log.d("TAG", "blah"); or using Roboguice's Ln Ln.d("blah"); I don't see any output in maven's surefire logs (text files). Ideally, I actually want simple log statements to go to the console. I can write to the console by using System.out.println("blah") , but of course I'd rather use the supported logging APIs. So my question is, why am I not seeing log output at all, and how can I get the log messages written to the console? I am running

Simple android application with roboguice throwing exceptions

早过忘川 提交于 2019-12-02 05:51:44
问题 I have a very simple application that works but when i add roboguice it throws java.lang.RuntimeException: Unable to instantiate application com.MyFirstApp.MyFirstApplication: java.lang.ClassNotFoundException: com.MyFirstApp.MyFirstApplication The application class: public class MyFirstApplication extends RoboApplication { @Override protected void addApplicationModules(List<Module> modules) { //modules.add(new DefaultModule()); } } The MainActivity: public class MainActivity extends

Simple android application with roboguice throwing exceptions

二次信任 提交于 2019-12-02 02:25:55
I have a very simple application that works but when i add roboguice it throws java.lang.RuntimeException: Unable to instantiate application com.MyFirstApp.MyFirstApplication: java.lang.ClassNotFoundException: com.MyFirstApp.MyFirstApplication The application class: public class MyFirstApplication extends RoboApplication { @Override protected void addApplicationModules(List<Module> modules) { //modules.add(new DefaultModule()); } } The MainActivity: public class MainActivity extends RoboActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Injected objects became null after upgrading to Roboguice 3

痴心易碎 提交于 2019-12-01 17:41:41
I've just upgraded our project to use Roboguice 3 and all of a sudden all the injected objects became null, that includes POJO, Providers, Views, Resources etc. And I'm struggling to figure out why. First of all there's the gradle build file, tried both Proguard on and off and it didn't make a difference. I believe we are currently using Roboguice 3.0.1, but I tried 3.0 and still had the problem. compile ('org.roboguice:roboguice:3.+') { exclude module: 'asm' } provided 'org.roboguice:roboblender:3.+ And we do have some custom bindings in a Module file, so here's how I'm specifying it