I am trying to create a dagger component interface in the test folder of android,but after Dagger is done with the generated class its show an error as \"Cannot access Test
I had the same problem here setting up my tests on our repo here. When seeing examples from Tivi, I noticed that our generated sources weren't being included to the source sets.
Adding a gradle script somewhere in your project should fix your problem.
Ex: https://github.com/toggl/android/blob/768f01b55c47ffd3bb7c4a82dea4abf50eac9e1c/database-android/build.gradle#L46-L63 (same as Tivi).
main.java.srcDirs += 'src/main/kotlin'
debug.java.srcDirs += 'src/debug/kotlin'
release.java.srcDirs += 'src/release/kotlin'
test.java.srcDirs += 'src/test/kotlin'
// For kapt stubs
main.java.srcDirs += [file("$buildDir/generated/source/kapt/main")]
debug.java.srcDirs += [file("$buildDir/generated/source/kapt/debug")]
release.java.srcDirs += [file("$buildDir/generated/source/kapt/release")]
test.java.srcDirs += [file("$buildDir/generated/source/kapt/test")]
// For kotlin code gen during kapt
main.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/main")]
debug.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/debug")]
release.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/release")]
test.java.srcDirs += [file("$buildDir/generated/source/kaptKotlin/test")]