본문 바로가기
개발/Android Error

[Error] JVM target 1.6. Please specify proper '-jvm-target' option

by JhDroid 2021. 3. 8.
728x90

에러 메시지

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6.
Please specify proper '-jvm-target' option

 

문제

  • 작성자는 EncryptSharedPreference 사용할 때 발생
encryptPref?.edit { //error in edit function
    ...
}

 

해결

  • 코틀린 컴파일러의 JVM 타깃이 맞지 않아서 발생하는 오류
  • App Gradle에 다음과 같은 설정을 추가해주면 해결
    • 안드로이드 스튜디오 최신버전의 경우 새로운 프로젝트를 생성하면 이미 선언되어 있음
android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

 

* 글에 틀린 부분이 있으면 댓글 부탁드립니다 :D

 

728x90