我正在开发一个Android应用程序使用喷气背包撰写和匕首刀柄,但当我运行项目,我得到以下错误
ApiModule.java:8: error: [Hilt]
public abstract interface ApiModule {
^
Found unimplemented abstract methods, [provideOpenWeatherApi()], in an abstract module, com.example.weathersforecast.di.ApiModule. Did you forget to add a Dagger binding annotation (e.g. @Binds)?
[Hilt] Processing did not complete. See error above for details.
AppModule.kt下
@Module
@InstallIn(SingletonComponent::class)
interface ApiModule {
@Singleton
@Provides
fun provideOpenWeatherApi(): WeatherApi {
return Retrofit.Builder()
.baseUrl(Constants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(WeatherApi::class.java)
}
}
我想知道我在哪里犯了错误我已经尝试了所有stackoverflow的答案它没有解决我的问题
1条答案
按热度按时间pod7payv1#
将AppModule从接口更改为对象,解决了我的问题