結論
Kotlin だけで書いてる Android のプロジェクトで Java8 が使われているライブラリを使用する場合でも、compileOptions が必要
(Kotlin だけ使ってるプロジェクトだと意識しないから忘れがち)
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
今回の現象との遭遇
material-components 1.1.0-alpha08 が出たので Kotlin だけで書いてるプロジェクトで使おうとしたら、以下の現象に遭遇しました。
- 実機デバッグの時にビルドは通るが layout の inflate でクラッシュしている
- assembleDebug をするとエラーが出る
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-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=21}.
よく見たら Java8 に依存してるて書いてるからもしかしてと思ったらそうだった