LoginSignup
3
3

More than 3 years have passed since last update.

AndroidアプリのJava/Kotlinコンパイル時オプションを指定する

Posted at

Android アプリを Gradle でビルドする際に -Xlint:deprecation-Xlint:unchecked などのコンパイルオプションを指定するメモ。JavaとKotlinで指定方法が異なるため注意。

build.gradle
allprojects {
    gradle.projectsEvaluated {

        // Javaコンパイル時
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }

        // Kotlinコンパイル時
        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
            kotlinOptions {
                freeCompilerArgs = [
                        "-Xjavac-arguments='-Xlint:unchecked -Xlint:deprecation'"
                ]
            }
        }
    }
}
3
3
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
3