vendredi 4 décembre 2020

Unresolved reference: HiltAndroidTest?

I'm trying to do test while using hilt, but whenever I add any hilt-test annotation it gives me that error. here is my gradle file

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlin-android-extensions'
id "androidx.navigation.safeargs.kotlin"}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
  kotlinOptions {
      jvmTarget = '1.8'
   }
 }
kapt {
   correctErrorTypes true
}

dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
def hiltDaggerVersion = '2.29-alpha'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

/* Testing */
// test kotlin
implementation 'androidx.test:core-ktx:1.3.0'
// fragment
debugImplementation "androidx.fragment:fragment-testing:1.2.5"
// hilt
androidTestImplementation "com.google.dagger:hilt-android-testing:2.29-alpha"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:2.29-alpha"
}

I used hilt in my code without a problem, but when i want to use it in the test, android studio doesn't recognize the annotation or the functions until i write the package name by myself, then when i run the test it gives me that error. What is the problem ?

Aucun commentaire:

Enregistrer un commentaire