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

2

6

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)}`
Runnels answered 8/9, 2022 at 5:20 Comment(0)
R
7

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

Runnels answered 8/9, 2022 at 6:0 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Manaus
C
7

Same issue

for annotation:

@Module

instead of the currect import:

import dagger.Module

Wrong import:

import com.google.android.datatransport.runtime.dagger.Myodule

or anything else

Curren answered 17/7, 2023 at 8:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.