LoginSignup
3
1

More than 3 years have passed since last update.

Kotlin のプロジェクトでもライブラリが Java8 に依存していれば compileOptions の指定が必要

Posted at

結論

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 に依存してるて書いてるからもしかしてと思ったらそうだった:sweat_smile:

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1