본문 바로가기

flutter앱개발과정

flutter 앱개발 - kotlin 버전 불일치 오류 해결

memo앱을 개발하던 중 아래와 같은 에러가 발생했습니다.

Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: C:\Users\wjswl\AppData\Local\Pub\Cache\hosted\pub.dev\google_mobile_ads-5.3.1\android\src\main\java\io\flutter\plugins\googlemobileads\AdMessageCodec.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 warnings
e: file:///C:/Users/wjswl/.gradle/caches/transforms-3/71f35512c85723ed13dfb9daaf1afe99/transformed/jetified-play-services-measurement-impl-22.2.0-api.jar!/META-INF/java.com.google.android.gms.libs.filecompliance.proto_file_access_api_type_kt_proto_lite.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
e: file:///C:/Users/wjswl/.gradle/caches/transforms-3/71f35512c85723ed13dfb9daaf1afe99/transformed/jetified-play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_only_for_use_in_proto_generated_code_its_generator_and_tests.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
e: file:///C:/Users/wjswl/.gradle/caches/transforms-3/71f35512c85723ed13dfb9daaf1afe99/transformed/jetified-play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_shared_runtime.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
e: file:///C:/Users/wjswl/.gradle/caches/transforms-3/b852c200df075b9ddbb8853d423cde4b/transformed/jetified-play-services-measurement-api-22.2.0-api.jar!/META-INF/java.com.google.android.gmscore.integ.client.measurement_api_measurement_api.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 1m 42s

┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                       │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then   │
│ update the                                                                                   │
│ version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of  │
│ C:\Users\wjswl\Desktop\flutter\workSpace\flutter_memo_app\android\settings.gradle.           │
│                                                                                              │
│ Alternatively (if your project was created before Flutter 3.19), update                      │
│ C:\Users\wjswl\Desktop\flutter\workSpace\flutter_memo_app\android\build.gradle               │
│ ext.kotlin_version = '<latest-version>'                                                      │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
Error: Gradle task assembleDebug failed with exit code 1

 

이 오류에 주요 원인은 kotlin 버전 불일치인데 

 

e: file:///C:/Users/wjswl/.gradle/caches/transforms-3/71f35512c85723ed13dfb9daaf1afe99/transformed/jetified-play-services-measurement-impl-22.2.0-api.jar!/META-INF/java.com.google.android.gms.libs.filecompliance.proto_file_access_api_type_kt_proto_lite.kotlin_moduleModule was compiled with an incompatible version of Kotlin. **The binary version of its metadata is 2.1.0, expected version is 1.8.0.**

오류에 이 부분을 보면 

- 라이브러리(Google Play Services 관련 파일)가 Kotlin 2.1.0 버전으로 컴파일되어있고

- 현재 프로젝트에서 기대하는 Kotlin 버전은 1.8.0 -> 버전이 불일치

- 프로젝트에서 쓰는 여러 라이브러리가 Kotlin 2.1.0을 요구하는데, 프로젝트는 1.8.0이라 충돌

때문에 kotlin을 2.1.0으로 맞춰주니 오류가 해결되었습니다.

 

오류를 고치는 과정에서 아래의 flutter 페이지를 참고했습니다.

https://docs.flutter.dev/release/breaking-changes/kotlin-version