@InstallIn-annotated classes must also be annotated with @Module or @EntryPoint error

Viewed 24

I don't know why I am receiving " @InstallIn-annotated classes must also be annotated with @Module or @EntryPoint: com.example.newsapp.di.AppModule [Hilt] Processing did not complete. See error above for details." error. I used the tutorial to write this code and the tutor's code (exactly the same as mine) works correctly. `

@Module
@InstallIn(SingletonComponent::class)
object AppModule {
  @Provides
    fun baseURL() = BASE_URL

    @Provides
    fun logging() = HttpLoggingInterceptor()
        .setLevel(HttpLoggingInterceptor.Level.BODY)

    @Provides
    fun okHttpClient() = okhttp3.OkHttpClient.Builder()
        .addInterceptor(logging())
        .build()


    @Provides
    @Singleton
    fun provideRetrofit(baseUrl: String): NewsService =
        Retrofit.Builder()
            .baseUrl(baseUrl)
            .addConverterFactory(GsonConverterFactory.create())
            .client(okHttpClient())
            .build()
            .create(NewsService::class.java)}`
1 Answers

I checked imports and found that I imported Module from the wrong place.

Related