草庐IT

androidannotations-dagger-example

全部标签

android - Dagger 注入(inject)可以用静态方法完成吗?

我有这个网络模块。我想在ErrorUtils的静态方法中注入(inject)网络模块。@ModulepublicclassNetworkModule{privatefinalStringEND_POINT="https://www.myurl.com/";@Provides@SingletonpublicOkHttpClientgetOkHttpClient(){OkHttpClientokHttpClient=builder.build();returnokHttpClient;}@Provides@SingletonpublicGsonConverterFactorygetGson

java - 在混合 Java/Kotlin 项目中使用 Dagger 2 的 Maven 配置

使用Dagger2的推荐Maven设置是什么?在混合Java/Kotlin项目中?我找到了一个使用Gradle的示例项目:https://github.com/damianpetla/kotlin-dagger-example与Maven类似的东西会非常有帮助。更新:我尝试了什么?我使用了kotlinlang.org/docs/reference/using-maven.html中的Kotlin配置以及来自google.github.io/dagger的Dagger配置.我还使用了build-helper-maven-plugin用于集成IDEA中的注释处理的插件。我的主要问题是我遇到

java - 在混合 Java/Kotlin 项目中使用 Dagger 2 的 Maven 配置

使用Dagger2的推荐Maven设置是什么?在混合Java/Kotlin项目中?我找到了一个使用Gradle的示例项目:https://github.com/damianpetla/kotlin-dagger-example与Maven类似的东西会非常有帮助。更新:我尝试了什么?我使用了kotlinlang.org/docs/reference/using-maven.html中的Kotlin配置以及来自google.github.io/dagger的Dagger配置.我还使用了build-helper-maven-plugin用于集成IDEA中的注释处理的插件。我的主要问题是我遇到

c++ - `class template Example<int>;` 语句对 C++11 意味着什么?

有人提到我"ExplicitTemplateInstantiation"在cplusplus.com,它给出了以下示例:templateclassExample{public:Example(Ttest){_data=test;}voidsetTest(Ttest){_data=T;}private:T_data;};classtemplateExample;classtemplateExample;classtemplateExample;除了在我看来是一个遗漏错误之外,试图将类型分配给成员变量--_data=T而不是我认为应该是_data=test--我不明白的是最后3行究竟声明或

android - Kotlin + Dagger2 : cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method

我收到以下错误:Error:(8,1)error:java.lang.Stringcannotbeprovidedwithoutan@Injectconstructororfroman@Provides-or@Produces-annotatedmethod.我一直在尝试制作一个提供两个合格字符串的模块。这是Dagger的简化设置。@Singleton@Component(modules=[GreetingsModule::class])interfaceAppComponent{funinject(activity:MainActivity)}@Qualifierannotation

android - Kotlin + Dagger2 : cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method

我收到以下错误:Error:(8,1)error:java.lang.Stringcannotbeprovidedwithoutan@Injectconstructororfroman@Provides-or@Produces-annotatedmethod.我一直在尝试制作一个提供两个合格字符串的模块。这是Dagger的简化设置。@Singleton@Component(modules=[GreetingsModule::class])interfaceAppComponent{funinject(activity:MainActivity)}@Qualifierannotation

android - Dagger2 Qualifier 不适用于 Kotlin?

我有一个简单的类如下classMainString(valmsg:String)我想给它注入(inject)不同的参数,所以我按照https://google.github.io/dagger/users-guide中显示的指南使用@Named限定符我的AppModule有了@Provides@Named("Two")funprovideTwoMainString():MainString{returnMainString("Two")}@Provides@Named("One")funprovideOneMainString():MainString{returnMainString

android - Dagger2 Qualifier 不适用于 Kotlin?

我有一个简单的类如下classMainString(valmsg:String)我想给它注入(inject)不同的参数,所以我按照https://google.github.io/dagger/users-guide中显示的指南使用@Named限定符我的AppModule有了@Provides@Named("Two")funprovideTwoMainString():MainString{returnMainString("Two")}@Provides@Named("One")funprovideOneMainString():MainString{returnMainString

java - 使用 Kotlin 创建自定义 Dagger 2 范围

我正在尝试将Java代码转换为Kotlin以创建自定义Dagger范围。这里是Java代码:@Documented@Scope@Retention(RetentionPolicy.RUNTIME)public@interfaceCustomScope{}这里转换成kotlin后就是结果@Scope@Documented@Retention(RetentionPolicy.RUNTIME)annotationclassCustomScope我的类型与@Retention(RetentionPolicy.RUNTIME)不匹配。我收到以下错误消息:RequiredTypeisAnnotat

java - 使用 Kotlin 创建自定义 Dagger 2 范围

我正在尝试将Java代码转换为Kotlin以创建自定义Dagger范围。这里是Java代码:@Documented@Scope@Retention(RetentionPolicy.RUNTIME)public@interfaceCustomScope{}这里转换成kotlin后就是结果@Scope@Documented@Retention(RetentionPolicy.RUNTIME)annotationclassCustomScope我的类型与@Retention(RetentionPolicy.RUNTIME)不匹配。我收到以下错误消息:RequiredTypeisAnnotat