반응형

안드로이드 스튜디오를 간만에 업데이트(3.4.2 버전)하고 새 프로젝트를 생성하고 빌드하다 보니 다음과 같은 에러가 발생하였다.

 

 Error: Invoke-customs are only supported starting with Android O (--min-api 26) 

 

무슨 에러인가 보았더니 역시나 친절한 안드로이드 스튜디오는 알려준다.

 

AGPBI: {"kind":"error","text":"Invoke-customs are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
> Task :app:mergeExtDexDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform artifact 'material.aar (com.google.android.material:material:1.1.0-alpha08)' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=24}
      > Execution failed for DexingTransform: /Users/noah/.gradle/caches/transforms-2/files-2.1/37a0daf16d8ba7dc17296903cb0a1c4f/jars/classes.jar.
         > Error while dexing.
           The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
           android {
               compileOptions {
                   sourceCompatibility 1.8
                   targetCompatibility 1.8
               }
           }
           See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.

 

고맙게도 해결방법까지 알려준다.

프로젝트를 생성할 때 이번에 변경된 안드로이드x 패키지를 사용하였는데 라이브러리 중에서 자바8 (JDK 8) 언어의 바이트코드를 의존성으로 가지고 있어 컴파일 옵션추가가 필요하다는 것 같다. ( Dex 쪽 문제인듯 싶다. )

 

 

 

원인 : 라이브러리의 JDK 버전 호환 문제

 

 

해결책 : 프로젝트 gradle 에서 android { ~ } 안에 다음과 같은 옵션 추가

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

 

반응형

+ Recent posts