Lint Rules
To help developers discover potential problems at compile time and keep API usage consistent,
BetterAndroidprovides a built-in set of Android Lint rules.
Rule List
The following are all Lint rules currently in effect.
ui-component
| Issue ID | Category | Severity | Priority | Brief Description |
|---|---|---|---|---|
| MultipleSystemBarsControllerProperties | CORRECTNESS | ERROR | 8 | Only one SystemBarsController property is allowed in a class. |
| ReplaceWithNotificationComponent | USABILITY | WARNING | 5 | Use ui-component's notification APIs instead. |
| ReplaceWithSystemBarsController | USABILITY | WARNING | 5 | Use ui-component's SystemBarsController instead. |
ui-component-adapter
| Issue ID | Category | Severity | Priority | Brief Description |
|---|---|---|---|---|
| ReplaceWithRecyclerAdapterExtension | USABILITY | WARNING | 5 | Use ui-component-adapter's RecyclerAdapter extensions instead. |
| ReplaceWithRecyclerViewExtension | USABILITY | WARNING | 5 | Use ui-component-adapter's RecyclerView extensions instead. |
ui-extension
| Issue ID | Category | Severity | Priority | Brief Description |
|---|---|---|---|---|
| ReplaceWithActivityExtension | USABILITY | WARNING | 5 | Use ui-extension's startActivity<T>(...) instead. |
| ReplaceWithBackPressedExtension | USABILITY | WARNING | 5 | Use ui-extension's back pressed extensions instead. |
| ReplaceWithBitmapExtension | USABILITY | WARNING | 5 | Use ui-extension's bitmap decode extensions instead. |
| ReplaceWithCoroutinesExtension | USABILITY | WARNING | 5 | Use ui-extension's coroutine extensions instead. |
| ReplaceWithContextExtension | USABILITY | WARNING | 5 | Use ui-extension's context host activity extensions instead. |
| ReplaceWithDrawableExtension | USABILITY | WARNING | 5 | Use ui-extension's Drawable.setPadding(size) instead. |
| ReplaceWithFragmentExtension | USABILITY | WARNING | 5 | Use ui-extension's fragment manager extensions instead. |
| ReplaceWithHandleOnWindowInsetsChanged | USABILITY | WARNING | 5 | Use ui-extension's handleOnWindowInsetsChanged(...) instead. |
| ReplaceWithLayoutInflaterExtension | USABILITY | WARNING | 5 | Use ui-extension's layoutInflater extension instead. |
| ReplaceWithLifecycleExtension | USABILITY | WARNING | 5 | Use ui-extension's lifecycle observer extensions instead. |
| ReplaceWithLifecycleOwnerExtension | USABILITY | WARNING | 5 | Use ui-extension's lifecycle owner extensions instead. |
| ReplaceWithRecyclerViewExtension | USABILITY | WARNING | 5 | Use ui-extension's RecyclerView.layoutManager() instead. |
| ReplaceWithResourcesExtension | USABILITY | WARNING | 5 | Use ui-extension's resources compat extensions instead. |
| ReplaceWithTextViewExtension | USABILITY | WARNING | 5 | Use ui-extension's TextView extensions instead. |
| ReplaceWithToastExtension | USABILITY | WARNING | 5 | Use ui-extension's toast(...) function instead of Toast.makeText(...).show(). |
| ReplaceWithViewBindingExtension | USABILITY | WARNING | 5 | Use ui-extension's ViewBinding extensions instead. |
| ReplaceWithViewExtension | USABILITY | WARNING | 5 | Use ui-extension's View.kt instead. |
| ReplaceWithViewImeExtension | USABILITY | WARNING | 5 | Use ui-extension's showIme() or hideIme() instead. |
| ReplaceWithViewOutlineProviderExtension | USABILITY | WARNING | 5 | Use ui-extension's outlineProvider(...) instead. |
| ReplaceWithViewTooltipTextCompatExtension | USABILITY | WARNING | 5 | Use ui-extension's tooltipTextCompat instead of TooltipCompat.setTooltipText(...) or ViewCompat.setTooltipText(...). |
| ReplaceWithViewWalkExtension | USABILITY | WARNING | 5 | Use ui-extension's walkToRoot() or walkThroughChildren() instead. |
system-extension
| Issue ID | Category | Severity | Priority | Brief Description |
|---|---|---|---|---|
| ReplaceWithAndroidVersion | USABILITY | WARNING | 5 | Use system-extension's AndroidVersion instead of Build.VERSION.SDK_INT. |
| ReplaceWithApplicationExtension | USABILITY | WARNING | 5 | Use system-extension's application extensions instead. |
| ReplaceWithBroadcastExtension | USABILITY | WARNING | 5 | Use system-extension's broadcast extensions instead. |
| ReplaceWithClipboardExtension | USABILITY | WARNING | 5 | Use system-extension's clipboard extensions instead. |
| ReplaceWithIntentExtension | USABILITY | WARNING | 5 | Use system-extension's intent extensions instead. |
| ReplaceWithServiceExtension | USABILITY | WARNING | 5 | Use 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:
ignorewarningerrorfatal
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 Issues.
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.
