Execution failed for task ':app:kaptDebugKotlin'. > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction > java.lang.reflect.InvocationTargetException (no error message)
I am getting this issue while setting Building the project while working with setup of Dagger 2
My Project Setup
Dependencies in build.gradle.kts:
dependencies {
implementation("com.google.dagger:dagger:2.40.5")
kapt("com.google.dagger:dagger-compiler:2.40.5")
implementation("com.google.dagger:dagger-android:2.40.5")
implementation("com.google.dagger:dagger-android-support:2.40.5")
kapt("com.google.dagger:dagger-android-processor:2.40.5")
}
Dagger Setup:
class UserRegistrationService @Inject constructor(
private val userRepository: UserRepository,
private val emailService: EmailService)
{
internal fun registerUser(email: String, password: String) {
emailService.send(email, "[email protected]", "User Registered")
}
}
@Component
interface UserRegistrationComponent {
fun getUserRegistrationService(): UserRegistrationService
}
Issue:
After syncing the project successfully, I tried rebuilding the project to get val userRegistration=DaggerUserRegistrationComponent.builder().build().getUserRegistrationService()
, but I am encountering the following error:
Execution failed for task ':app:kaptDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
java.lang.reflect.InvocationTargetException (no error message)`
What I Have Tried:
- Ensuring that all dependencies are correctly added.
- Cleaning and rebuilding the project.
- Invalidating caches and restarting Android Studio.
- Instead of
kapt("com.google.dagger:dagger-compiler:2.40.5")
in dependencies, I tried
annotationProcessor("com.google.dagger:dagger-compiler:2.40.5")
, using this project rebuild is successful, but unable to getDaggerUserRegistrationComponent.builder().build().getUserRegistrationService()
Shiv Sagar Singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.