본문 바로가기

Develop/Android

[Flutter/Android] 안드로이드 프로젝트 gradle 충돌

문제 발단

과거 제작해두었던 Flutter 패키지를 업데이트하고 안드로이드 기기에서 테스트 시도중 빌드실패

FAILURE: Build failed with an exception.

* Where:
Build file '.../example/android/build.gradle' line: 13

* What went wrong:
A problem occurred evaluating root project 'android'.
> Build completed with 1 failures.
   > 'org.gradle.api.artifacts.Dependency org.gradle.api.artifacts.dsl.DependencyHandler.module(java.lang.Object)'

* 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 generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 9s
Error: Gradle task assembleDebug failed with exit code 1

example의 안드로이드 프로젝트에서 빌드를 시도하다가 Gradle 버전이 맞지 않음을 확인

Your build is currently configured to use incompatible Java 21.0.9 and Gradle 7.6.3. Cannot sync the project.

We recommend upgrading to Gradle version 9.0.0.

The minimum compatible Gradle version is 8.5.

The maximum compatible Gradle JVM version is 19.

Possible solutions:
 - Upgrade to Gradle 9.0.0 and re-sync
 - Upgrade to Gradle 8.5 and re-sync

Gradle을 9.0.0으로 업그레이드했지만 그래도 빌드 실패

Unable to find method ''org.gradle.api.artifacts.Dependency org.gradle.api.artifacts.dsl.DependencyHandler.module(java.lang.Object)''
'org.gradle.api.artifacts.Dependency org.gradle.api.artifacts.dsl.DependencyHandler.module(java.lang.Object)'

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

 

해결방법

이 프로젝트의 gradle은 7.X 버전이었으며 AndroidStudio에서 권장하는 min version은 8.5 버전으로 gradle 버전 수정필요성 확인

1. example/android/settings.gradle 수정

...
plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.7.3" apply false	//버전 수정 AS-IS 7.3.0
    id "org.jetbrains.kotlin.android" version "2.1.21" apply false	//버전 수정 AS-IS 1.7.10
}
...

 

2. AGP 버전 업데이트/마이그레이션

3. Java/Kotlin 버전 확인
example/android/app/build.gradle complieOptions에 명시된 version을 수정하여 kotlin버전과 java버전을 동기화시킬 수 있으니 마이그레이션 이후에도 빌드 에러가 발생한다면 확인 필요

반응형

'Develop > Android' 카테고리의 다른 글

hilt 의존성 추가  (0) 2025.10.23
Android Gradle 업그레이드 이슈  (3) 2025.02.07
Android Studio 업그레이드  (4) 2024.01.15
Singleton VS Application class  (3) 2019.09.04
Android CustomView 만드는 방법 (Java) #2  (1) 2019.07.24