dagger-2

Dagger 2 does not generate the component class (Android, Kotlin)

a 夏天 提交于 2019-12-11 10:12:21
问题 Basically, I wanted to test if TheCoffee was automatically "injected". But I could not find DaggerMyComponent . I think I must have done something wrong, but what? Under the MainActivity, @Component(modules=arrayOf(MyModule::class)) @Singleton interface MyComponent { fun inject(coffee: CoffeeShop) } @Module class MyModule { @Provides @Singleton @ForApplication fun provideCoffee():Coffee { return Coffee("Bad coffee"); } } data class Coffee(var Name:String) class CoffeeShop { @Inject var

Dagger and libgdx

懵懂的女人 提交于 2019-12-11 08:57:30
问题 Is it possible to use dagger 2 and libgdx web? The libgdx project builds fine with android and desktop. When I add a web module and run with ./gradlew html:superDev [ERROR] Line 1: The type javax.inject.Named cannot be resolved. It is indirectly referenced from required .class files [ERROR] Line 30: The import dagger.Lazy cannot be resolved [ERROR] Line 32: The import javax.inject.Inject cannot be resolved [ERROR] Line 37: Inject cannot be resolved to a type After following this http://www.g

View not updating after first time triggering LiveData when using background job in Android

折月煮酒 提交于 2019-12-11 08:07:35
问题 I'm building a debt application in Android using Dagger 2, Room and MVVM. My problem lies with the reactivity of my main view, where a list of debts are shown and you can tick them off. When this activity is launched all the debts are loaded correctly, however when I insert a new debt the view is not updated accordingly . The strange part is that when I tick one of them off the view refreshes as expected. After much debugging I can infer that the problem has to do with the Lifecycle of the

How to fix undefined MqttChannelInitializer constructor in HiveMQ Client?

大城市里の小女人 提交于 2019-12-11 07:48:51
问题 I was using HiveMQ Client version 1.0.1 but I decided to update to the recently released version 1.1. I completely started from scratch and imported the project as a Gradle project and tried to build. The build work only after ignoring a few failed tests. I'm getting 3 errors in 3 different classes. I realize this is likely related to the Dagger dependency injection tool and I had already successfully built the project and added the directory of build/generated/source/apt/main/ to my build

Firebase Test Lab fails when using ProGuard + Dagger

别来无恙 提交于 2019-12-11 06:50:00
问题 Instrumented tests do pass on local emulators and physical devices but fail on Firebase Test Lab, when the following conditions are met: ProGuard is enabled for the debug builds; There are both Dagger and Espresso dependencies. FTL shows different test issues: 1) In case with APIs 26-28 it shows either Instrumentation run failed due to 'java.lang.NoClassDefFoundError' or Instrumentation run failed due to 'Process crashed.' Exception stacktrace looks like this, it's not always shown in

How can I swap test doubles at the scope of an Activity or a Fragment using Dagger 2?

岁酱吖の 提交于 2019-12-11 06:45:26
问题 EDIT: Watch out! I have deleted the old repository reffered to in this question. See my own answer to the question for a possible solution and feel free to improve it! I am refering to my post here. Now I came a little further. I am also refering to my two branches within my github Project: Experimental [branch no. 1] (repository deleted) Experimental [branch no. 2] (repository deleted) In the old post I tried to swap components to test-components within an Instrumentation Test. This works

Dagger 2 not injecting in interface type

痞子三分冷 提交于 2019-12-11 06:38:22
问题 I an trying to inject a field in an interface type which is implemented by a class. Here is what i have done so far. These are view interface: public interface PostView extends View, ListView<Post>, EmptyView<String> { } public interface View { public void showProgressIndicator(); public void hideProgressIndicator(); public void onSuccess(); public void onFailure(); public void onFailure(String message); } public interface ListView<E> { public void onListItems(List<E> items, int pageNum, int

Dagger/MissingBinding java.util.Map<java.lang.Class<? extends ViewModel>,Provider<ViewModel>> cannot be provided without an @Provides-annotated method

断了今生、忘了曾经 提交于 2019-12-11 06:14:23
问题 This is how I'm trying to provide my ViewModelFactory : @Suppress("UNCHECKED_CAST") @Singleton class ViewModelFactory @Inject constructor( private val viewModels: MutableMap<Class<out ViewModel>, Provider<ViewModel>> ) : ViewModelProvider.Factory { override fun <T : ViewModel?> create(modelClass: Class<T>): T = viewModels[modelClass]?.get() as T } @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @kotlin.annotation.Retention

Android implementing HostSelectionInterceptor for dynamic change url using Dagger 2

穿精又带淫゛_ 提交于 2019-12-11 05:26:05
问题 i just learn about how can i implementing Retrofit with Dagger2 to set dynamic change url on this reference i try to make simple module with HostSelectionInterceptor class to use that on Dagger2, but i can't make that correctly and i get error: my NetworkModule : @Module(includes = ContextModule.class) public class NetworkModule { @Provides @AlachiqApplicationScope public HttpLoggingInterceptor loggingInterceptor() { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(new

Inject object with @ActivityScope in @ViewScope

我与影子孤独终老i 提交于 2019-12-11 04:51:08
问题 I'm using dagger 2.11 and it's not possible to inject Views out of the box, but I managed to do so: BindingModule: @Module(subcomponents = {...}) public abstract class ViewBindingModule { @Binds @IntoMap @ViewKey(MyView.class) abstract AndroidInjector.Factory<? extends BaseView> myView(MyViewSubComponent.Builder builder); } MyViewSubComponent: @Subcomponent(modules = MyViewModule.class) public interface MyViewSubComponent extends AndroidInjector<MyView> { @Subcomponent.Builder abstract class