I am building a hilt project and when i am building it, it is giving me this 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)
- Try:
Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
This is the build.gradle file(Module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.android.practice"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
//hilt
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-compiler:2.38.1"
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
kapt {
correctErrorTypes = true
}
UserApplication Class
@HiltAndroidApp
class UserApplication : Application() {
@Inject
lateinit var userRepository:UserRepository
override fun onCreate() {
super.onCreate()
userRepository.saveUser("rahmat@gmail.com","pass123")
}
}
User Repository Class
class UserRepository @Inject constructor() {
fun saveUser(email:String, password:String){
Log.e("User Repository","User saved")
}
}
'Error Screenshot [1]: https://i.stack.imgur.com/GDxWe.png
Can anyone help me with this?
Thanks in advance.