Android 관련

Unsupported class file major version 65

이나주니 2025. 5. 22. 13:41
반응형

 

아래의 오류가 난다면?

 

BUG! exception in phase 'semantic analysis' in source unit 'C:\workspace\flutter_3.22.0\flutter\packages\flutter_tools\gradle\src\main\groovy\app_plugin_loader.groovy' Unsupported class file major version 65

 

 

 

Java 21에서 컴파일된 .class 파일을 의미

Gradle이 Java 21을 지원하지 않아서 생기는 오류임

 

Java 버전 17로 맞추기

https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html

 

Java Archive Downloads - Java SE 17.0.12 and earlier

WARNING: Older versions of the JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production. For production use Oracle recommends downloading the late

www.oracle.com

다운로드 후

 

JAVA_HOME 경로 설정

 

JAVA_HOME "C:\Program Files\Java\jdk-17"

 

cmd 확인

 

 

만약 run 할 경우

 

'compileDebugJavaWithJavac' task (current target is 1.8) and 'kspDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.  이런 오류가 난다?

 

app/build.gradle

android {
 compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }
}

 

이렇게 변경

 

사용자의 경우 17이 자꾸 안잡혀서

org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError
org.gradle.java.home=C:/Program Files/Java/jdk-17
android.useAndroidX=true
android.enableJetifier=true

 

이렇게 강제로 설정

 

해결~

반응형