[Planit 프로젝트 문제 해결] 안드로이드 에뮬레이터로 디버깅 중 발생한 일

KangHo Lee's avatar
Feb 11, 2025
[Planit 프로젝트 문제 해결] 안드로이드 에뮬레이터로 디버깅 중 발생한 일

1. 문제 발생

notion image
Flutter Fix
[!] This is likely due to a known bug in Android Gradle Plugin (AGP) versions less than 8.2.1, │ │ when │ │ 1. setting a value for SourceCompatibility and │ │ 2. using Java 21 or above. │ │ To fix this error, please upgrade your AGP version to at least 8.2.1. The version of AGP that │ │ your project uses is likely defined in: │ │ C:\workspace\flutter_lec\projectplanit\android\settings.gradle, │ │ in the 'plugins' closure (by the number following "com.android.application"). │ │ Alternatively, if your project was created with an older version of the templates, it is likely │ │ in the buildscript.dependencies closure of the top-level build.gradle: │ │ C:\workspace\flutter_lec\projectplanit\android\build.gradle, │ │ as the number following "com.android.tools.build:gradle:". │ │ │ │ For more information, see: │ │ https://issuetracker.google.com/issues/294137077 │ │ https://github.com/flutter/flutter/issues/156304
  • 안드로이드 에뮬레이터 실행 시 이런 에러가 뜨면서 디버그가 되지 않았습니다.

2. ChatGPT에 질문

  • Flutter 프로젝트에서 발생한 오류는 Android Gradle Plugin(AGP) 버전과 Java 버전 간의 호환성 문제로 인해 발생했습니다. 이를 해결하기 위해 다음 단계를 따라 AGP 버전을 업데이트하세요
    • Java는 21을 쓰고 있었습니다.
buildscript { dependencies { classpath 'com.android.tools.build:gradle:8.2.1' } }
  • projectplanit\android\build.gradle 파일을 수정하라고 했지만 적용이 되지 않았습니다.

3. 인터넷 검색 → stackoverflow.com에서 해결법 확인

gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
  • 하지만 원래 설정이 gradle-8.3-all.zip 이었고 8.2로 바꿔도 해결되지 않았습니다.

4. 검색을 하면서 Java 버전과 AGP 버전과 Gradle 버전이 다름을 알 수 있었습니다.

  • Java 21은 AGP 8.2.1 이상을 요구하고 AGP 8.2.1은 Gradle 8.1 이상을 요구합니다.
  • distributionUrl은 gradle 버전을 설정하기 때문에 해결법이 되지 못했습니다.

5. 다른 gpt인 copilot 에게 AGP 버전 설정법을 물었습니다.

  • projectplanit\android\setting.gradle
plugins { id 'com.android.application' version 'AGP_VERSION' }
  • 현재 AGP 버전은 8.1.0이었고 8.2.1로 변경하니 문제가 해결되었습니다.

6. 어쩌다 이런 일이 발생했을까?

  • 프로젝트 생성 과정을 되돌아봤습니다.
  • 노트북에서 프로젝트를 생성했었고 노트북의 JAVA는 17 버전이었습니다.
  • 데스크톱은 JAVA 21 버전을 사용 중이었고 노트북에서 생성한 프로젝트를 데스크톱에 옮겨서 실행하면서 문제가 발생한 것이었습니다.
 
Share article

devleekangho