nueijeel

[Android] CompilationErrorException 오류 본문

Android/에러 및 문제 해결

[Android] CompilationErrorException 오류

nueijeel 2023. 8. 22. 22:18

 

프로젝트 작업 중 기능 구현을 하고 프로그램을 실행시켰더니 갑자기 오류가 발생했다

 

app:compileDebugKotlin

org.jetbrains.kotlin.gradle.tasks.CompilationErrorException : Compilation error

 

와 같은 에러가 났다고  표시됐고 빌드 오류라 로그캣도 이용할 수 없었다.

오류 났다고 표시된 MainActivity.kt의 15번째 줄도 import 문이었기 때문에 발생 이유를 찾기가 힘들었다.

 

 

구글링 해도 별 다른 해결책을 찾지 못하던 때

 

https://stackoverflow.com/questions/62131564/a-failure-occurred-while-executing-org-jetbrains-kotlin-gradle-internal-kaptexec

 

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

All of sudden I start getting this error, and I am not getting idea why if anyone just let me know where this error is, will be enough helpful. As much I am able to get is this because of new updat...

stackoverflow.com

 

스택오버플로 페이지에서 터미널을 이용해 더 자세한 오류 내용을 볼 수 있다는 내용을 발견했다!

 

./gradlew assembleDebug --stacktrace

 

안드로이드 스튜디오 터미널에서 위 명령어를 실행했더니 아래와 같은 오류 메시지가 나왔다..!

 

FAILURE: Build failed with an exception.
* What went wrong: A problem occurred configuring root project 'CampingUsProject-seller'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:8.0.2.
Required by:project :> com.android.application:com.android.application.gradle.plugin:8.0.2 project : > com.android.library:com.android.library.gradle.plugin:8.0.2 > No matching variant of com.android.tools.build:gradle:8.0.2 was found. The consumer was configured to find a library for use dur ing runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' but: - Variant 'apiElements' capability com.android.tools.build:gradle:8.0.2 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.0') - Variant 'javadocElements' capability com.android.tools.build:gradle:8.0.2 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.0') - Variant 'runtimeElements' capability com.android.tools.build:gradle:8.0.2 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '8.0') - Variant 'sourcesElements' capability com.android.tools.build:gradle:8.0.2 declares a component for use during runtime, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '8.0') * Try: > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. * Exception is: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'CampingUsProject-seller'.

 

정확하게는 모르겠지만 계속 build.gradle 8.0.2 library 라는 말이 반복적으로 나오는 걸 보니 

빌드 파일에 문제가 생겼나 싶었다.

 

 

https://kjmhercules.tistory.com/7

 

[해결방법] compileDebugKotlin Exception 간단하게 해결하기

몇일 전까지만 해도 잘 빌드하고 있던 프로젝트를 다시 빌드하는 도중에 아래와 같은 에러가 발생하였다. 손댄게 없는데 왜 이러지?? (물론 중간에 다른 Flutter 버전의 프로젝트를 손댄것도 있고

kjmhercules.tistory.com

 

위 링크에서 코틀린 버전을 변경하라고 해서

 

id 'org.jetbrains.kotlin.android' version '1.8.20' apply false

 

이 코드를 아래와 같이 변경해 sync 해줬더니

id 'org.jetbrains.kotlin.android' version '1.9.0' apply false

 

 

성공적으로 빌드되어 실행되었다!!!!

 

 

 

안드로이드 스튜디오 내에서 오류에 대한 정보가 너무 안나와서 해결하는 데 오래걸렸지만

그래도 터미널 명령어를 사용해서 오류 내용을 더 자세히 보는 방법을 알게되었다!

 

 

 

 

 

728x90