Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - how to migrate from LintOptions to Lint in a plugin of a multi-module app

I have a multi-module app which uses a plugin to handle common settings for modules. One of the things I configure are some lint options. So far this was my implementation:

class MyPlugin : Plugin<Project> {
    override fun apply(project: Project) {
        project.plugins.apply("kotlin-android")
        val androidExtension = project.extensions.getByName("android")
        if (androidExtension is BaseExtension) {
            androidExtension.apply {
                lintOptions {
                    isAbortOnError = false
                    //other settings
                }
            }
        }
}

I am getting warnings about deprecation such as:

'isAbortOnError: Boolean' is deprecated. Overrides deprecated member in 'com.android.build.api.dsl.LintOptions'. Moved to lint.abortOnError

I would like to move to Lint as suggested, but BaseExtension does not have lint, only lintOptions. How to do it?

like image 884
suue Avatar asked Nov 02 '25 09:11

suue


1 Answers

You can use this in

project.configure<com.android.build.api.dsl.ApplicationExtension> {
   lint {
        abortOnError = true
    }
}

I'm using it with AGP 8.1.0-alpha10, but it will be probably valid also in older AGP.

BaseExtension is now part of the internal API and just because of compatibility with older projects.

You should now depend only on com.android.tools.build:gradle-api artifact instead of com.android.tools.build:gradle

At least in an ideal situation.

like image 179
ATom Avatar answered Nov 03 '25 22:11

ATom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!