본문 바로가기
Development Solutions/Flutter & Dart

[Java][Flutter] Gradle과 JDK 버전 확인 및 변경 방법

by Dev Diary Hub 2024. 1. 28.
반응형

How to check and change Gradle and JDK versions

Gradle과 JDK 버전 확인 및 변경 방법

[Java][Flutter]

 
 
Gradle과 JDK는 Android 애플리케이션을 빌드하는 데 필수적인 요소입니다.
이들 간의 호환성은 프로젝트의 성공적인 빌드와 실행에 매우 중요합니다.
 
이 글에서는 Gradle과 JDK 버전의 호환성을 확인하고, 필요에 따라 버전을 변경하는 방법에 대해 설명합니다.
 
(Eng> Gradle and JDK are essential components for building Android applications.
Compatibility between them is critical to the successful build and execution of a project.
This article explains how to check Gradle and JDK version compatibility and change the version as needed.)
 
 

1. 호환성 확인:

Gradle과 JDK 호환성: (Eng> Gradle and JDK compatibility:)

  • Gradle은 JDK 버전에 따라 다르게 동작할 수 있으며, 각 Gradle 버전은 특정 JDK 버전과 호환됩니다. Gradle 공식 문서나 릴리스 노트에서 호환성 정보를 확인할 수 있습니다.
  • Android Studio는 프로젝트에 적합한 Gradle 및 JDK 버전을 자동으로 제안하기도 합니다.

(Eng> Gradle may behave differently depending on the JDK version, and each Gradle version is compatible with a specific JDK version. You can check compatibility information in Gradle's official documentation or release notes.
Android Studio also automatically suggests appropriate Gradle and JDK versions for your project.)
 
↓ Java & Kotlin - Gradle 간 버전 호환성 체크 (Eng> Java & Kotlin - Check version compatibility between Gradle)
https://docs.gradle.org/current/userguide/compatibility.html

Compatibility Matrix

The sections below describe Gradle’s compatibility with several integrations. Versions not listed here may or may not work.

docs.gradle.org

 
↓ Android Gradle 플러그인 - Gradle 간 버전 호환성 체크 (Eng> Android Gradle plugin - Check version compatibility between Gradle)

반응형

https://developer.android.com/studio/releases/gradle-plugin?hl=ko#groovy

Android Gradle 플러그인 출시 노트  |  Android 개발자  |  Android Developers

Android 스튜디오 빌드 시스템은 Gradle을 기반으로 하며 Android Gradle 플러그인에는 Android 앱을 빌드하는 데 사용하는 몇 가지 추가 기능이 있습니다.

developer.android.com

 

2. Gradle 버전 변경:

build.gradle 파일 수정: (Eng> 2. Change Gradle version: Edit build.gradle file:)

  • 프로젝트 루트의 build.gradle 파일을 열고 dependencies 섹션에서 classpath에 지정된 Gradle 플러그인 버전을 변경합니다.

(Eng> Open the build.gradle file in the project root and in the dependencies section change the Gradle plugin version specified in the classpath.)

dependencies {
    classpath 'com.android.tools.build:gradle:7.0.3'
}

 
gradle-wrapper.properties 파일 수정:

  • gradle/wrapper/gradle-wrapper.properties 파일에서 distributionUrl을 수정하여 사용할 Gradle 버전을 지정합니다.

(Eng> Edit gradle-wrapper.properties file: Specify the Gradle version to use by modifying distributionUrl in the gradle/wrapper/gradle-wrapper.properties file.)

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip

 
Android Studio 설정(Eng> Android Studio settings:)

  • Android Studio에서는 File > Project Structure에서 프로젝트의 Gradle 버전을 변경할 수 있습니다. Project 섹션에서 Grade 버전을 확인하고 필요한 경우 수정합니다.

(Eng> In Android Studio, you can change the Gradle version of your project in File > Project Structure. Check the Grade version in the Project section and modify it if necessary.)

 

3. JDK 버전 변경:

환경 변수 설정: (Eng> 3. Change JDK version: Setting environment variables:)

  • 시스템의 JAVA_HOME 환경 변수가 올바른 JDK 버전을 가리키고 있는지 확인하고, 필요하다면 수정합니다. JAVA_HOME은 JDK가 설치된 디렉토리를 가리켜야 합니다.

(Eng> Verify that your system's JAVA_HOME environment variable points to the correct JDK version, and modify it if necessary. JAVA_HOME must point to the directory where the JDK is installed.)
 
Android Studio 설정: (Eng> Android Studio settings:)

  • Android Studio에서는 AndroidStudio > Settings 에서 프로젝트의 JDK 버전을 변경할 수 있습니다. Build,Execution,Deployment > Build Tools > Gradle 섹션에서 JDK 경로를 확인하고 필요한 경우 수정합니다.

(Eng> In Android Studio, you can change the JDK version of your project in File > Project Structure. In the Build,Execution,Deployment > Build Tools > Gradle section, check the JDK path and modify it if necessary.)
 

 
Gradle 설정: (Eng> Gradle settings:)

  • Gradle이 사용하는 JDK 버전은 gradle.properties 파일에 org.gradle.java.home 속성을 통해 설정할 수 있습니다.

(Eng> The JDK version used by Gradle can be set through the org.gradle.java.home property in the gradle.properties file.)

org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_251

 
 

4. 확인 및 테스트: (Eng> 4. Check and test:)

  • 버전 변경 후에는 프로젝트를 깨끗하게 빌드하고 (Build > Clean Project), 다시 빌드하여 (Build > Rebuild Project) 모든 것이 제대로 작동하는지 확인합니다.

(Eng> After the version change, do a clean build of the project (Build > Clean Project) and rebuild (Build > Rebuild Project) to make sure everything works properly.)
 
 

Gradle과 JDK의 버전 호환성은 안드로이드 애플리케이션 개발의 안정성과 성능에 직접적인 영향을 미칩니다. 따라서 프로젝트 요구 사항과 공식 문서를 참조하여 적절한 버전을 선택하는 것이 중요합니다.

(Eng> Gradle and JDK version compatibility directly affects the stability and performance of Android application development. Therefore, it is important to refer to your project requirements and official documentation to select the appropriate version.)

반응형