Lint Rules

To help developers discover potential problems at compile time and keep API usage consistent, BetterAndroid provides a built-in set of Android Lint rules.

Rule List

The following are all Lint rules currently in effect.

ui-component

Issue IDCategorySeverityPriorityBrief Description
MultipleSystemBarsControllerPropertiesopen in new windowCORRECTNESSERROR8Only one SystemBarsController property is allowed in a class.
ReplaceWithNotificationComponentopen in new windowUSABILITYWARNING5Use ui-component's notification APIs instead.
ReplaceWithSystemBarsControlleropen in new windowUSABILITYWARNING5Use ui-component's SystemBarsController instead.

ui-component-adapter

Issue IDCategorySeverityPriorityBrief Description
ReplaceWithRecyclerAdapterExtensionopen in new windowUSABILITYWARNING5Use ui-component-adapter's RecyclerAdapter extensions instead.
ReplaceWithRecyclerViewExtensionopen in new windowUSABILITYWARNING5Use ui-component-adapter's RecyclerView extensions instead.

ui-extension

Issue IDCategorySeverityPriorityBrief Description
ReplaceWithActivityExtensionopen in new windowUSABILITYWARNING5Use ui-extension's startActivity<T>(...) instead.
ReplaceWithBackPressedExtensionopen in new windowUSABILITYWARNING5Use ui-extension's back pressed extensions instead.
ReplaceWithBitmapExtensionopen in new windowUSABILITYWARNING5Use ui-extension's bitmap decode extensions instead.
ReplaceWithCoroutinesExtensionopen in new windowUSABILITYWARNING5Use ui-extension's coroutine extensions instead.
ReplaceWithContextExtensionopen in new windowUSABILITYWARNING5Use ui-extension's context host activity extensions instead.
ReplaceWithDrawableExtensionopen in new windowUSABILITYWARNING5Use ui-extension's Drawable.setPadding(size) instead.
ReplaceWithFragmentExtensionopen in new windowUSABILITYWARNING5Use ui-extension's fragment manager extensions instead.
ReplaceWithHandleOnWindowInsetsChangedopen in new windowUSABILITYWARNING5Use ui-extension's handleOnWindowInsetsChanged(...) instead.
ReplaceWithLayoutInflaterExtensionopen in new windowUSABILITYWARNING5Use ui-extension's layoutInflater extension instead.
ReplaceWithLifecycleExtensionopen in new windowUSABILITYWARNING5Use ui-extension's lifecycle observer extensions instead.
ReplaceWithLifecycleOwnerExtensionopen in new windowUSABILITYWARNING5Use ui-extension's lifecycle owner extensions instead.
ReplaceWithRecyclerViewExtensionopen in new windowUSABILITYWARNING5Use ui-extension's RecyclerView.layoutManager() instead.
ReplaceWithResourcesExtensionopen in new windowUSABILITYWARNING5Use ui-extension's resources compat extensions instead.
ReplaceWithTextViewExtensionopen in new windowUSABILITYWARNING5Use ui-extension's TextView extensions instead.
ReplaceWithToastExtensionopen in new windowUSABILITYWARNING5Use ui-extension's toast(...) function instead of Toast.makeText(...).show().
ReplaceWithViewBindingExtensionopen in new windowUSABILITYWARNING5Use ui-extension's ViewBinding extensions instead.
ReplaceWithViewExtensionopen in new windowUSABILITYWARNING5Use ui-extension's View.kt instead.
ReplaceWithViewImeExtensionopen in new windowUSABILITYWARNING5Use ui-extension's showIme() or hideIme() instead.
ReplaceWithViewOutlineProviderExtensionopen in new windowUSABILITYWARNING5Use ui-extension's outlineProvider(...) instead.
ReplaceWithViewTooltipTextCompatExtensionopen in new windowUSABILITYWARNING5Use ui-extension's tooltipTextCompat instead of TooltipCompat.setTooltipText(...) or ViewCompat.setTooltipText(...).
ReplaceWithViewWalkExtensionopen in new windowUSABILITYWARNING5Use ui-extension's walkToRoot() or walkThroughChildren() instead.

system-extension

Issue IDCategorySeverityPriorityBrief Description
ReplaceWithAndroidVersionopen in new windowUSABILITYWARNING5Use system-extension's AndroidVersion instead of Build.VERSION.SDK_INT.
ReplaceWithApplicationExtensionopen in new windowUSABILITYWARNING5Use system-extension's application extensions instead.
ReplaceWithBroadcastExtensionopen in new windowUSABILITYWARNING5Use system-extension's broadcast extensions instead.
ReplaceWithClipboardExtensionopen in new windowUSABILITYWARNING5Use system-extension's clipboard extensions instead.
ReplaceWithIntentExtensionopen in new windowUSABILITYWARNING5Use system-extension's intent extensions instead.
ReplaceWithServiceExtensionopen in new windowUSABILITYWARNING5Use system-extension's service extensions instead.

How to Disable or Adjust Rules

If you want to disable a specific rule or change its severity, you can create a lint.xml file in the project root.

The following example

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="ReplaceWithViewExtension" severity="ignore" />
    <issue id="ReplaceWithAndroidVersion" severity="error" />
</lint>

Common severity values are:

  • ignore
  • warning
  • error
  • fatal

You can also control them directly in Gradle.

The following example

android {
    lint {
        disable += "ReplaceWithViewExtension"
        warning += "ReplaceWithToastExtension"
        error += "ReplaceWithAndroidVersion"
    }
}

If you only want to check part of the rules, you can also use checkOnly.

The following example

android {
    lint {
        checkOnly += setOf(
            "ReplaceWithViewExtension",
            "ReplaceWithAndroidVersion"
        )
    }
}

Feedback

Currently, most Lint detectors are completed by AI Agent, and there may still be issues, such as complex UAST scenarios that have not been tested. If you find that a Lint rule is misreporting or the Quick Fix cannot correctly fix the problem during use, you can provide an Issue ID to directly feedback to us on GitHub Issuesopen in new window.

If you think some rules are not reasonable and overly restrictive on the code, or if you have some new rule suggestions, please also feel free to provide feedback to us, and we will evaluate and adjust them.