Andorid
[Android Hilt] Hilt 적용 중 > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution > java.lang.reflect.InvocationTargetException (no error message) 에러 해결
CoBool
2022. 3. 29. 23:35
Hilt를 적용하기 위해 애플리케이션 클래스에 어노테이션을 다음과 같이 달았다.
@HiltAndroidApp
class SocketApplication : Application() {
companion object {
var appContext : Context? = null
}
override fun onCreate() {
super.onCreate()
appContext = this
KakaoSdk.init(this,getString(R.string.kakao_app_key))
}
}
그러자 빌드에 실패한 뒤 다음과 같은 오류가 떴다.
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
참조한 블로그들의 조언대로 build.gradle 파일을 다음과 같이 수정했다.
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.miso.weatherchat"
targetSdkVersion 30
minSdkVersion 21
...
}
...
}
compileSdkVersion과 minSdkVersion을 전부 30으로 변경했다.
그러자 또 다음과 같은 오류가 발생했다.
The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-30).
Dependency: androidx.core:core-ktx:1.7.0.
AAR metadata file: ....
이후 앱 수준의 build.gradle에
android {
...
defaultConfig {
...
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
}
...
}
dependencies {
...
implementation 'androidx.appcompat:appcompat:1.4.0'->
implementation 'androidx.appcompat:appcompat:1.3.0'
...
}
defaultConfig에 위의 내용을 추가하고,appcompat의 버전을 1.4.0→1.3.0으로 변경하니
더 이상 오류가 발생되지 않았다.
https://velog.io/@jeongsick82/Android-Execution-failed-for-task-appkaptDebugKotlin