title: Injecting ViewModel using DaggerHilt fails to to compile
body: <p>I read the <a href="https://developer.android.com/training/dependency-injection/hilt-jetpack" rel="noreferrer">documentation</a> on using Dagger Hilt to inject ViewModels. I tried to implement in my application but the I consistently get an error during gradle build and the project does not compile. How can I fix this issue ?</p>
  <pre><code>/home/amcap1712/Documents/MusicBrainzAndroid/app/src/main/java/org/metabrainz/mobile/presentation/features/artist/ArtistViewModel.java:19: error: [Hilt]
  public class ArtistViewModel extends LookupViewModel {
         ^
    org.metabrainz.mobile.presentation.features.artist.ArtistViewModel, expected to be annotated with @DefineComponent. Found: 
    [Hilt] Processing did not complete. See error above for details.warning: File for type 'org.metabrainz.mobile.App_HiltComponents' created in the last round will not be subject to annotation processing.
  </code></pre>
  <p>Here are the relevant files,<br />
  <strong>build.gradle</strong></p>
  <pre><code>....
  dependencies {
          classpath 'com.android.tools.build:gradle:4.1.0-beta02'
          classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
          classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
  }
  ....
  </code></pre>
  <p><strong>app/build.gradle</strong></p>
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'
  apply plugin: 'kotlin-kapt'
  apply plugin: 'dagger.hilt.android.plugin'
  
  android {
      compileSdkVersion 29
      defaultConfig {
          applicationId &quot;org.metabrainz.android&quot;
          minSdkVersion 16
          targetSdkVersion 29
          versionCode 33
  
          versionName &quot;3.1&quot;
          multiDexEnabled true
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
      }
  
      buildFeatures {
          viewBinding = true
          dataBinding = true
      }
  
      buildTypes {
          release {
              minifyEnabled false
              // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      lintOptions{
          disable 'InvalidPackage'
          disable 'MissingTranslation'
      }
      compileOptions {
          sourceCompatibility = '1.8'
          targetCompatibility = '1.8'
      }
  
      ndkVersion '21.2.6472646'
  }
  
  dependencies {
      implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
      implementation &quot;androidx.navigation:navigation-fragment:$navigationVersion&quot;
      implementation &quot;androidx.navigation:navigation-ui:$navigationVersion&quot;
      implementation 'androidx.lifecycle:lifecycle-runtime:2.3.0-alpha05'
      implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha05'
      implementation 'androidx.lifecycle:lifecycle-viewmodel:2.3.0-alpha05'
      implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
      implementation 'androidx.lifecycle:lifecycle-common-java8:2.3.0-alpha05'
      implementation 'androidx.legacy:legacy-support-v4:1.0.0'
      implementation 'androidx.core:core-ktx:1.3.0'
      implementation &quot;androidx.activity:activity:1.1.0&quot;
      implementation &quot;androidx.fragment:fragment-ktx:1.2.5&quot;
  
      //webservice Setup
      implementation 'com.google.code.gson:gson:2.8.6'
      implementation 'com.squareup.retrofit2:retrofit:2.7.1'
      implementation 'com.squareup.okhttp3:okhttp:4.3.1'
      implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
      implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
  
      //Image downloading and Caching library
      implementation 'com.squareup.picasso:picasso:2.71828'
  
      //Kotlin setup
      implementation &quot;org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version&quot;
      implementation &quot;org.jetbrains.kotlin:kotlin-reflect:$kotlin_version&quot;
  
      //Fragment Setup For Kotlin
      implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0-rc02'
      implementation 'androidx.navigation:navigation-ui-ktx:2.0.0-rc02'
      implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
  
      //Test Setup
      testImplementation 'junit:junit:4.13'
      androidTestImplementation 'androidx.test:runner:1.2.0'
      androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  
      //Tagger &amp; Metadata Setup
      implementation 'com.github.QuickLyric:fpcalc-android:1.0.1'
      implementation 'org.bitbucket.ijabz:jaudiotagger:android-SNAPSHOT'
      implementation 'info.debatty:java-string-similarity:1.2.1'
  
      //Design Setup
      implementation 'androidx.browser:browser:1.2.0'
      implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha04'
      implementation 'androidx.cardview:cardview:1.0.0'
      implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta8'
      implementation &quot;com.google.android.material:material:$supportlibVersion&quot;
      implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
      implementation 'io.reactivex.rxjava2:rxjava:2.2.17'
      implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
      implementation 'androidx.preference:preference:1.1.1'
      implementation 'me.dm7.barcodescanner:zbar:1.9.13'
      implementation &quot;com.airbnb.android:lottie:$lottieVersion&quot;
  
      implementation &quot;androidx.paging:paging-runtime:3.0.0-alpha02&quot;
  
      implementation &quot;com.google.dagger:hilt-android:2.28-alpha&quot;
      implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01'
      implementation &quot;com.google.dagger:dagger:2.28&quot;
      annotationProcessor &quot;com.google.dagger:dagger-compiler:2.28&quot;
      annotationProcessor &quot;com.google.dagger:hilt-android-compiler:2.28-alpha&quot;
      annotationProcessor 'androidx.hilt:hilt-compiler:1.0.0-alpha01'
      kapt &quot;com.google.dagger:dagger-compiler:2.28&quot;
      kapt &quot;com.google.dagger:hilt-android-compiler:2.28-alpha&quot;
      kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha01'
  }
  
  </code></pre>
  <p><strong>ArtistViewModel.java</strong>
  This class extends another an abstract LookupViewModel class I created with some common functions I use in many viewmodels.</p>
  <pre class="lang-java prettyprint-override"><code>....
  public class ArtistViewModel extends LookupViewModel {
      ....
      @ViewModelInject
      public ArtistViewModel(LookupRepository repository) {
          super(repository);
          .....
      }
  ....
  </code></pre>
  <p><strong>LookupRepositor.java</strong></p>
  <pre class="lang-java prettyprint-override"><code>....
  @Module
  @InstallIn(ArtistViewModel.class)
  public class LookupRepository {
      private static LookupRepository repository;
      
      private LookupRepository() {
      }
  
      @Singleton
      @Provides
      public static LookupRepository getRepository() {
          if (repository == null) repository = new LookupRepository();
          return repository;
      }
  ....
  </code></pre>