6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Default interface methods are only supported starting with Android N (--min-api 24)の対処法

Posted at

apkをビルドしようとして

Default interface methods are only supported starting with Android N (--min-api 24)

とか

com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process 

とかのエラーが出てビルドできないときの対処法

# 原因
Java8の機能を使うようなコードを書いているのに、コンパイルオプションでJava8の指定を忘れている

解決方法

android {
    ...
defaultConfig {
        ...
        compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    }
   
}

build.gradleのdefaultConfig{}の中にJava8のコンパイルオプションを指定する

  • ライブラリだけがjava8の機能使うっていう時にライブラリモジュールのbuild.gradleにだけ書いていて、app/build.gradleには書いていなかったらビルド通らなかったので注意
  • starting with Android N (--min-api 24)とか言っている割にminSdkVersionは21でも全然大丈夫だった
6
4
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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?