Skip to content

Instantly share code, notes, and snippets.

@cuchas
Created April 2, 2018 12:29
Show Gist options
  • Save cuchas/b00e0f9d511ce69a2316d83697bd222a to your computer and use it in GitHub Desktop.
Save cuchas/b00e0f9d511ce69a2316d83697bd222a to your computer and use it in GitHub Desktop.
Correctness
===========
OnClick
-------
Summary: onClick method does not exist
Priority: 10 / 10
Severity: Error
Category: Correctness
The onClick attribute value should be the name of a method in this View's
context to invoke when the view is clicked. This name must correspond to a
public method that takes exactly one parameter of type View.
Must be a string value, using '\;' to escape characters such as '\n' or
'\uxxxx' for a unicode character.
MissingPermission
-----------------
Summary: Missing Permissions
Priority: 9 / 10
Severity: Error
Category: Correctness
This check scans through your code and libraries and looks at the APIs being
used, and checks this against the set of permissions required to access those
APIs. If the code using those APIs is called at runtime, then the program will
crash.
Furthermore, for permissions that are revocable (with targetSdkVersion 23),
client code must also be prepared to handle the calls throwing an exception if
the user rejects the request for permission at runtime.
MissingSuperCall
----------------
Summary: Missing Super Call
Priority: 9 / 10
Severity: Error
Category: Correctness
Some methods, such as View#onDetachedFromWindow, require that you also call
the super implementation as part of your method.
ResAuto
-------
Summary: Hardcoded Package in Namespace
Priority: 9 / 10
Severity: Fatal
Category: Correctness
In Gradle projects, the actual package used in the final APK can vary; for
example,you can add a .debug package suffix in one version and not the other.
Therefore, you should not hardcode the application package in the resource;
instead, use the special namespace http://schemas.android.com/apk/res-auto
which will cause the tools to figure out the right namespace for the resource
regardless of the actual package used during the build.
WrongViewCast
-------------
Summary: Mismatched view type
Priority: 9 / 10
Severity: Fatal
Category: Correctness
Keeps track of the view types associated with ids and if it finds a usage of
the id in the Java code it ensures that it is treated as the same type.
AaptCrash
---------
Summary: Potential AAPT crash
Priority: 8 / 10
Severity: Fatal
Category: Correctness
Defining a style which sets android:id to a dynamically generated id can cause
many versions of aapt, the resource packaging tool, to crash. To work around
this, declare the id explicitly with <item type="id" name="..." /> instead.
More information:
https://code.google.com/p/android/issues/detail?id=20479
GradleCompatible
----------------
Summary: Incompatible Gradle Versions
Priority: 8 / 10
Severity: Error
Category: Correctness
There are some combinations of libraries, or tools and libraries, that are
incompatible, or can lead to bugs. One such incompatibility is compiling with
a version of the Android support libraries that is not the latest version (or
in particular, a version lower than your targetSdkVersion.)
GradlePluginVersion
-------------------
Summary: Incompatible Android Gradle Plugin
Priority: 8 / 10
Severity: Error
Category: Correctness
Not all versions of the Android Gradle plugin are compatible with all versions
of the SDK. If you update your tools, or if you are trying to open a project
that was built with an old version of the tools, you may need to update your
plugin version number.
MergeMarker
-----------
Summary: Code contains merge marker
Priority: 8 / 10
Severity: Error
Category: Correctness
Many version control systems leave unmerged files with markers such as <<< in
the source code. This check looks for these markers, which are sometimes
accidentally left in, particularly in resource files where they don't break
compilation.
MissingLeanbackLauncher
-----------------------
Summary: Missing Leanback Launcher Intent Filter.
Priority: 8 / 10
Severity: Error
Category: Correctness
An application intended to run on TV devices must declare a launcher activity
for TV in its manifest using a android.intent.category.LEANBACK_LAUNCHER
intent filter.
More information:
https://developer.android.com/training/tv/start/start.html#tv-activity
MissingRegistered
-----------------
Summary: Missing registered class
Priority: 8 / 10
Severity: Error
Category: Correctness
If a class is referenced in the manifest or in a layout file, it must also
exist in the project (or in one of the libraries included by the project. This
check helps uncover typos in registration names, or attempts to rename or move
classes without updating the manifest file properly.
More information:
http://developer.android.com/guide/topics/manifest/manifest-intro.html
MockLocation
------------
Summary: Using mock location provider in production
Priority: 8 / 10
Severity: Fatal
Category: Correctness
Using a mock location provider (by requiring the permission
android.permission.ACCESS_MOCK_LOCATION) should only be done in debug builds
(or from tests). In Gradle projects, that means you should only request this
permission in a test or debug source set specific manifest file.
To fix this, create a new manifest file in the debug folder and move the
<uses-permission> element there. A typical path to a debug manifest override
file in a Gradle project is src/debug/AndroidManifest.xml.
NamespaceTypo
-------------
Summary: Misspelled namespace declaration
Priority: 8 / 10
Severity: Fatal
Category: Correctness
Accidental misspellings in namespace declarations can lead to some very
obscure error messages. This check looks for potential misspellings to help
track these down.
NotInterpolated
---------------
Summary: Incorrect Interpolation
Priority: 8 / 10
Severity: Error
Category: Correctness
To insert the value of a variable, you can use ${variable} inside a string
literal, but only if you are using double quotes!
More information:
http://www.groovy-lang.org/syntax.html#_string_interpolation
PendingBindings
---------------
Summary: Missing Pending Bindings
Priority: 8 / 10
Severity: Error
Category: Correctness
When using a ViewDataBinding in a onBindViewHolder method, you must call
executePendingBindings() before the method exits; otherwise the data binding
runtime will update the UI in the next animation frame causing a delayed
update and potential jumps if the item resizes.
Proguard
--------
Summary: Using obsolete ProGuard configuration
Priority: 8 / 10
Severity: Fatal
Category: Correctness
Using -keepclasseswithmembernames in a proguard config file is not correct; it
can cause some symbols to be renamed which should not be.
Earlier versions of ADT used to create proguard.cfg files with the wrong
format. Instead of -keepclasseswithmembernames use -keepclasseswithmembers,
since the old flags also implies "allow shrinking" which means symbols only
referred to from XML and not Java (such as possibly CustomViews) can get
deleted.
More information:
http://http://code.google.com/p/android/issues/detail?id=16384
RecyclerView
------------
Summary: RecyclerView Problems
Priority: 8 / 10
Severity: Error
Category: Correctness
RecyclerView will not call onBindViewHolder again when the position of the
item changes in the data set unless the item itself is invalidated or the new
position cannot be determined.
For this reason, you should only use the position parameter while acquiring
the related data item inside this method, and should not keep a copy of it.
If you need the position of an item later on (e.g. in a click listener), use
getAdapterPosition() which will have the updated adapter position.
ReferenceType
-------------
Summary: Incorrect reference types
Priority: 8 / 10
Severity: Fatal
Category: Correctness
When you generate a resource alias, the resource you are pointing to must be
of the same type as the alias
ResourceCycle
-------------
Summary: Cycle in resource definitions
Priority: 8 / 10
Severity: Fatal
Category: Correctness
There should be no cycles in resource definitions as this can lead to runtime
exceptions.
ResourceName
------------
Summary: Resource with Wrong Prefix
Priority: 8 / 10
Severity: Fatal
Category: Correctness
In Gradle projects you can specify a resource prefix that all resources in the
project must conform to. This makes it easier to ensure that you don't
accidentally combine resources from different libraries, since they all end up
in the same shared app namespace.
StringShouldBeInt
-----------------
Summary: String should be int
Priority: 8 / 10
Severity: Error
Category: Correctness
The properties compileSdkVersion, minSdkVersion and targetSdkVersion are
usually numbers, but can be strings when you are using an add-on (in the case
of compileSdkVersion) or a preview platform (for the other two properties).
However, you can not use a number as a string (e.g. "19" instead of 19); that
will result in a platform not found error message at build/sync time.
UnknownId
---------
Summary: Reference to an unknown id
Priority: 8 / 10
Severity: Fatal
Category: Correctness
The @+id/ syntax refers to an existing id, or creates a new one if it has not
already been defined elsewhere. However, this means that if you have a typo in
your reference, or if the referred view no longer exists, you do not get a
warning since the id will be created on demand. This check catches errors
where you have renamed an id without updating all of the references to it.
WrongFolder
-----------
Summary: Resource file in the wrong res folder
Priority: 8 / 10
Severity: Fatal
Category: Correctness
Resource files are sometimes placed in the wrong folder, and it can lead to
subtle bugs that are hard to understand. This check looks for problems in this
area, such as attempting to place a layout "alias" file in a layout/ folder
rather than the values/ folder where it belongs.
DalvikOverride
--------------
Summary: Method considered overridden by Dalvik
Priority: 7 / 10
Severity: Error
Category: Correctness
The Android virtual machine will treat a package private method in one class
as overriding a package private method in its super class, even if they are in
separate packages. This may be surprising, but for compatibility reasons the
behavior has not been changed (yet).
If you really did intend for this method to override the other, make the
method protected instead.
If you did not intend the override, consider making the method private, or
changing its name or signature.
DuplicateIds
------------
Summary: Duplicate ids within a single layout
Priority: 7 / 10
Severity: Fatal
Category: Correctness
Within a layout, id's should be unique since otherwise findViewById() can
return an unexpected view.
MissingTvBanner
---------------
Summary: TV Missing Banner
Priority: 7 / 10
Severity: Error
Category: Correctness
A TV application must provide a home screen banner for each localization if it
includes a Leanback launcher intent filter. The banner is the app launch point
that appears on the home screen in the apps and games rows.
More information:
http://developer.android.com/training/tv/start/start.html#banner
ResourceAsColor
---------------
Summary: Should pass resolved color instead of resource id
Priority: 7 / 10
Severity: Error
Category: Correctness
Methods that take a color in the form of an integer should be passed an RGB
triple, not the actual color resource id. You must call
getResources().getColor(resource) to resolve the actual color value first.
ResourceType
------------
Summary: Wrong Resource Type
Priority: 7 / 10
Severity: Fatal
Category: Correctness
Ensures that resource id's passed to APIs are of the right type; for example,
calling Resources.getColor(R.string.name) is wrong.
WebViewLayout
-------------
Summary: WebViews in wrap_content parents
Priority: 7 / 10
Severity: Error
Category: Correctness
The WebView implementation has certain performance optimizations which will
not work correctly if the parent view is using wrap_content rather than
match_parent. This can lead to subtle UI bugs.
DuplicateDefinition
-------------------
Summary: Duplicate definitions of resources
Priority: 6 / 10
Severity: Error
Category: Correctness
You can define a resource multiple times in different resource folders; that's
how string translations are done, for example. However, defining the same
resource more than once in the same resource folder is likely an error, for
example attempting to add a new resource without realizing that the name is
already used, and so on.
GradleGetter
------------
Summary: Gradle Implicit Getter Call
Priority: 6 / 10
Severity: Error
Category: Correctness
Gradle will let you replace specific constants in your build scripts with
method calls, so you can for example dynamically compute a version string
based on your current version control revision number, rather than hardcoding
a number.
When computing a version name, it's tempting to for example call the method to
do that getVersionName. However, when you put that method call inside the
defaultConfig block, you will actually be calling the Groovy getter for the
versionName property instead. Therefore, you need to name your method
something which does not conflict with the existing implicit getters. Consider
using compute as a prefix instead of get.
ImpliedTouchscreenHardware
--------------------------
Summary: Hardware feature touchscreen not explicitly marked as optional
Priority: 6 / 10
Severity: Error
Category: Correctness
Apps require the android.hardware.touchscreen feature by default. If you want
your app to be available on TV, you must also explicitly declare that a
touchscreen is not required as follows:
<uses-feature android:name="android.hardware.touchscreen"
android:required="false"/>
More information:
https://developer.android.com/guide/topics/manifest/uses-feature-element.html
Instantiatable
--------------
Summary: Registered class is not instantiatable
Priority: 6 / 10
Severity: Fatal
Category: Correctness
Activities, services, broadcast receivers etc. registered in the manifest file
(or for custom views, in a layout file) must be "instantiatable" by the
system, which means that the class must be public, it must have an empty
public constructor, and if it's an inner class, it must be a static inner
class.
InvalidAnalyticsName
--------------------
Summary: Invalid Analytics Name
Priority: 6 / 10
Severity: Error
Category: Correctness
Event names and parameters must follow the naming conventions defined in
the`FirebaseAnalytics#logEvent()` documentation.
More information:
http://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#logEvent(java.lang.String,%20android.os.Bundle)
InvalidId
---------
Summary: Invalid ID declaration
Priority: 6 / 10
Severity: Fatal
Category: Correctness
An id definition must be of the form @+id/yourname. The tools have not
rejected strings of the form @+foo/bar in the past, but that was an error, and
could lead to tricky errors because of the way the id integers are assigned.
If you really want to have different "scopes" for your id's, use prefixes
instead, such as login_button1 and login_button2.
InvalidPackage
--------------
Summary: Package not included in Android
Priority: 6 / 10
Severity: Error
Category: Correctness
This check scans through libraries looking for calls to APIs that are not
included in Android.
When you create Android projects, the classpath is set up such that you can
only access classes in the API packages that are included in Android. However,
if you add other projects to your libs/ folder, there is no guarantee that
those .jar files were built with an Android specific classpath, and in
particular, they could be accessing unsupported APIs such as java.applet.
This check scans through library jars and looks for references to API packages
that are not included in Android and flags these. This is only an error if
your code calls one of the library classes which wind up referencing the
unsupported package.
InvalidResourceFolder
---------------------
Summary: Invalid Resource Folder
Priority: 6 / 10
Severity: Error
Category: Correctness
This lint check looks for a folder name that is not a valid resource folder
name; these will be ignored and not packaged by the Android Gradle build
plugin.
Note that the order of resources is very important; for example, you can't
specify a language before a network code.
Similarly, note that to use 3 letter region codes, you have to use a special
BCP 47 syntax: the prefix b+ followed by the BCP 47 language tag but with + as
the individual separators instead of -. Therefore, for the BCP 47 language tag
nl-ABW you have to use b+nl+ABW.
More information:
http://developer.android.com/guide/topics/resources/providing-resources.html
https://tools.ietf.org/html/bcp47
InvalidUsesTagAttribute
-----------------------
Summary: Invalid name attribute for uses element.
Priority: 6 / 10
Severity: Error
Category: Correctness
The <uses> element in <automotiveApp> should contain a valid value for the
name attribute.
Valid values are media or notification.
More information:
https://developer.android.com/training/auto/start/index.html#auto-metadata
LibraryCustomView
-----------------
Summary: Custom views in libraries should use res-auto-namespace
Priority: 6 / 10
Severity: Fatal
Category: Correctness
When using a custom view with custom attributes in a library project, the
layout must use the special namespace http://schemas.android.com/apk/res-auto
instead of a URI which includes the library project's own package. This will
be used to automatically adjust the namespace of the attributes when the
library resources are merged into the application project.
ManifestResource
----------------
Summary: Manifest Resource References
Priority: 6 / 10
Severity: Fatal
Category: Correctness
Elements in the manifest can reference resources, but those resources cannot
vary across configurations (except as a special case, by version, and except
for a few specific package attributes such as the application title and
icon.)
MissingConstraints
------------------
Summary: Missing Constraints in ConstraintLayout
Priority: 6 / 10
Severity: Error
Category: Correctness
The layout editor allows you to place widgets anywhere on the canvas, and it
records the current position with designtime attributes (such as
layout_editor_absoluteX.) These attributes are not applied at runtime, so if
you push your layout on a device, the widgets may appear in a different
location than shown in the editor. To fix this, make sure a widget has both
horizontal and vertical constraints by dragging from the edge connections.
MissingIntentFilterForMediaSearch
---------------------------------
Summary: Missing intent-filter with action
android.media.action.MEDIA_PLAY_FROM_SEARCH
Priority: 6 / 10
Severity: Error
Category: Correctness
To support voice searches on Android Auto, you should also register an
intent-filter for the action android.media.action.MEDIA_PLAY_FROM_SEARCH.
To do this, add
<intent-filter>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
</intent-filter>
to your <activity> or <service>.
More information:
https://developer.android.com/training/auto/audio/index.html#support_voice
MissingLeanbackSupport
----------------------
Summary: Missing Leanback Support.
Priority: 6 / 10
Severity: Error
Category: Correctness
The manifest should declare the use of the Leanback user interface required by
Android TV.
To fix this, add
<uses-feature android:name="android.software.leanback"
android:required="false" />
to your manifest.
More information:
https://developer.android.com/training/tv/start/start.html#leanback-req
MissingMediaBrowserServiceIntentFilter
--------------------------------------
Summary: Missing intent-filter with action
android.media.browse.MediaBrowserService.
Priority: 6 / 10
Severity: Error
Category: Correctness
An Automotive Media App requires an exported service that extends
android.service.media.MediaBrowserService with an intent-filter for the action
android.media.browse.MediaBrowserService to be able to browse and play media.
To do this, add
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
to the service that extends android.service.media.MediaBrowserService
More information:
https://developer.android.com/training/auto/audio/index.html#config_manifest
MissingOnPlayFromSearch
-----------------------
Summary: Missing onPlayFromSearch.
Priority: 6 / 10
Severity: Error
Category: Correctness
To support voice searches on Android Auto, in addition to adding an
intent-filter for the action onPlayFromSearch, you also need to override and
implement onPlayFromSearch(String query, Bundle bundle)
More information:
https://developer.android.com/training/auto/audio/index.html#support_voice
MissingPrefix
-------------
Summary: Missing Android XML namespace
Priority: 6 / 10
Severity: Error
Category: Correctness
Most Android views have attributes in the Android namespace. When referencing
these attributes you must include the namespace prefix, or your attribute will
be interpreted by aapt as just a custom attribute.
Similarly, in manifest files, nearly all attributes should be in the android:
namespace.
MultipleUsesSdk
---------------
Summary: Multiple <uses-sdk> elements in the manifest
Priority: 6 / 10
Severity: Fatal
Category: Correctness
The <uses-sdk> element should appear just once; the tools will not merge the
contents of all the elements so if you split up the attributes across multiple
elements, only one of them will take effect. To fix this, just merge all the
attributes from the various elements into a single <uses-sdk> element.
More information:
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
NewApi
------
Summary: Calling new methods on older versions
Priority: 6 / 10
Severity: Error
Category: Correctness
This check scans through all the Android API calls in the application and
warns about any calls that are not available on all versions targeted by this
application (according to its minimum SDK attribute in the manifest).
If you really want to use this API and don't need to support older devices
just set the minSdkVersion in your build.gradle or AndroidManifest.xml files.
If your code is deliberately accessing newer APIs, and you have ensured (e.g.
with conditional execution) that this code will only ever be called on a
supported platform, then you can annotate your class or method with the
@TargetApi annotation specifying the local minimum SDK to apply, such as
@TargetApi(11), such that this check considers 11 rather than your manifest
file's minimum SDK as the required API level.
If you are deliberately setting android: attributes in style definitions, make
sure you place this in a values-vNN folder in order to avoid running into
runtime conflicts on certain devices where manufacturers have added custom
attributes whose ids conflict with the new ones on later platforms.
Similarly, you can use tools:targetApi="11" in an XML file to indicate that
the element will only be inflated in an adequate context.
NotSibling
----------
Summary: RelativeLayout Invalid Constraints
Priority: 6 / 10
Severity: Fatal
Category: Correctness
Layout constraints in a given RelativeLayout should reference other views
within the same relative layout (but not itself!)
Override
--------
Summary: Method conflicts with new inherited method
Priority: 6 / 10
Severity: Error
Category: Correctness
Suppose you are building against Android API 8, and you've subclassed
Activity. In your subclass you add a new method called isDestroyed(). At some
later point, a method of the same name and signature is added to Android. Your
method will now override the Android method, and possibly break its contract.
Your method is not calling super.isDestroyed(), since your compilation target
doesn't know about the method.
The above scenario is what this lint detector looks for. The above example is
real, since isDestroyed() was added in API 17, but it will be true for any
method you have added to a subclass of an Android class where your build
target is lower than the version the method was introduced in.
To fix this, either rename your method, or if you are really trying to augment
the builtin method if available, switch to a higher build target where you can
deliberately add @Override on your overriding method, and call super if
appropriate etc.
OverrideAbstract
----------------
Summary: Not overriding abstract methods on older platforms
Priority: 6 / 10
Severity: Fatal
Category: Correctness
To improve the usability of some APIs, some methods that used to be abstract
have been made concrete by adding default implementations. This means that
when compiling with new versions of the SDK, your code does not have to
override these methods.
However, if your code is also targeting older versions of the platform where
these methods were still abstract, the code will crash. You must override all
methods that used to be abstract in any versions targeted by your
application's minSdkVersion.
PropertyEscape
--------------
Summary: Incorrect property escapes
Priority: 6 / 10
Severity: Error
Category: Correctness
All backslashes and colons in .property files must be escaped with a backslash
(\). This means that when writing a Windows path, you must escape the file
separators, so the path \My\Files should be written as key=\\My\\Files.
Range
-----
Summary: Outside Range
Priority: 6 / 10
Severity: Error
Category: Correctness
Some parameters are required to in a particular numerical range; this check
makes sure that arguments passed fall within the range. For arrays, Strings
and collections this refers to the size or length.
ServiceCast
-----------
Summary: Wrong system service casts
Priority: 6 / 10
Severity: Fatal
Category: Correctness
When you call Context#getSystemService(), the result is typically cast to a
specific interface. This lint check ensures that the cast is compatible with
the expected type of the return value.
Suspicious0dp
-------------
Summary: Suspicious 0dp dimension
Priority: 6 / 10
Severity: Error
Category: Correctness
Using 0dp as the width in a horizontal LinearLayout with weights is a useful
trick to ensure that only the weights (and not the intrinsic sizes) are used
when sizing the children.
However, if you use 0dp for the opposite dimension, the view will be
invisible. This can happen if you change the orientation of a layout without
also flipping the 0dp dimension in all the children.
UniquePermission
----------------
Summary: Permission names are not unique
Priority: 6 / 10
Severity: Fatal
Category: Correctness
The unqualified names or your permissions must be unique. The reason for this
is that at build time, the aapt tool will generate a class named Manifest
which contains a field for each of your permissions. These fields are named
using your permission unqualified names (i.e. the name portion after the last
dot).
If more than one permission maps to the same field name, that field will
arbitrarily name just one of them.
UnsupportedTvHardware
---------------------
Summary: Unsupported TV Hardware Feature
Priority: 6 / 10
Severity: Error
Category: Correctness
The <uses-feature> element should not require this unsupported TV hardware
feature. Any uses-feature not explicitly marked with required="false" is
necessary on the device to be installed on. Ensure that any features that
might prevent it from being installed on a TV device are reviewed and marked
as not required in the manifest.
More information:
https://developer.android.com/training/tv/start/hardware.html#unsupported-features
ValidFragment
-------------
Summary: Fragment not instantiatable
Priority: 6 / 10
Severity: Fatal
Category: Correctness
From the Fragment documentation:
Every fragment must have an empty constructor, so it can be instantiated when
restoring its activity's state. It is strongly recommended that subclasses do
not have other constructors with parameters, since these constructors will not
be called when the fragment is re-instantiated; instead, arguments can be
supplied by the caller with setArguments(Bundle) and later retrieved by the
Fragment with getArguments().
More information:
http://developer.android.com/reference/android/app/Fragment.html#Fragment()
WifiManagerLeak
---------------
Summary: WifiManager Leak
Priority: 6 / 10
Severity: Fatal
Category: Correctness
On versions prior to Android N (24), initializing the WifiManager via
Context#getSystemService can cause a memory leak if the context is not the
application context. Change context.getSystemService(...) to
context.getApplicationContext().getSystemService(...).
WrongCall
---------
Summary: Using wrong draw/layout method
Priority: 6 / 10
Severity: Fatal
Category: Correctness
Custom views typically need to call measure() on their children, not
onMeasure. Ditto for onDraw, onLayout, etc.
WrongManifestParent
-------------------
Summary: Wrong manifest parent
Priority: 6 / 10
Severity: Fatal
Category: Correctness
The <uses-library> element should be defined as a direct child of the
<application> tag, not the <manifest> tag or an <activity> tag. Similarly, a
<uses-sdk> tag must be declared at the root level, and so on. This check looks
for incorrect declaration locations in the manifest, and complains if an
element is found in the wrong place.
More information:
http://developer.android.com/guide/topics/manifest/manifest-intro.html
WrongThread
-----------
Summary: Wrong Thread
Priority: 6 / 10
Severity: Error
Category: Correctness
Ensures that a method which expects to be called on a specific thread, is
actually called from that thread. For example, calls on methods in widgets
should always be made on the UI thread.
More information:
http://developer.android.com/guide/components/processes-and-threads.html#Threads
AppCompatResource
-----------------
Summary: Menu namespace
Priority: 5 / 10
Severity: Error
Category: Correctness
When using the appcompat library, menu resources should refer to the
showAsAction in the app: namespace, not the android: namespace.
Similarly, when not using the appcompat library, you should be using the
android:showAsAction attribute.
AppLinksAutoVerifyError
-----------------------
Summary: App Links Auto Verification Failure
Priority: 5 / 10
Severity: Error
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable AppLinksAutoVerifyError
Ensures that app links are correctly set and associated with website.
More information:
https://g.co/appindexing/applinks
DuplicateActivity
-----------------
Summary: Activity registered more than once
Priority: 5 / 10
Severity: Fatal
Category: Correctness
An activity should only be registered once in the manifest. If it is
accidentally registered more than once, then subtle errors can occur, since
attribute declarations from the two elements are not merged, so you may
accidentally remove previous declarations.
FullBackupContent
-----------------
Summary: Valid Full Backup Content File
Priority: 5 / 10
Severity: Fatal
Category: Correctness
Ensures that a <full-backup-content> file, which is pointed to by a
android:fullBackupContent attribute in the manifest file, is valid
More information:
http://android-developers.blogspot.com/2015/07/auto-backup-for-apps-made-simple.html
IncludeLayoutParam
------------------
Summary: Ignored layout params on include
Priority: 5 / 10
Severity: Error
Category: Correctness
Layout parameters specified on an <include> tag will only be used if you also
override layout_width and layout_height on the <include> tag; otherwise they
will be ignored.
More information:
http://stackoverflow.com/questions/2631614/does-android-xml-layouts-include-tag-really-work
LogTagMismatch
--------------
Summary: Mismatched Log Tags
Priority: 5 / 10
Severity: Error
Category: Correctness
When guarding a Log.v(tag, ...) call with Log.isLoggable(tag), the tag passed
to both calls should be the same. Similarly, the level passed in to
Log.isLoggable should typically match the type of Log call, e.g. if checking
level Log.DEBUG, the corresponding Log call should be Log.d, not Log.i.
LongLogTag
----------
Summary: Too Long Log Tags
Priority: 5 / 10
Severity: Error
Category: Correctness
Log tags are only allowed to be at most 23 tag characters long.
ManifestTypo
------------
Summary: Typos in manifest tags
Priority: 5 / 10
Severity: Fatal
Category: Correctness
This check looks through the manifest, and if it finds any tags that look like
likely misspellings, they are flagged.
NetworkSecurityConfig
---------------------
Summary: Valid Network Security Config File
Priority: 5 / 10
Severity: Fatal
Category: Correctness
Ensures that a <network-security-config> file, which is pointed to by an
android:networkSecurityConfig attribute in the manifest file, is valid
More information:
https://developer.android.com/preview/features/security-config.html
NfcTechWhitespace
-----------------
Summary: Whitespace in NFC tech lists
Priority: 5 / 10
Severity: Fatal
Category: Correctness
In a <tech-list>, there can be whitespace around the <tech> elements,but not
inside them. This is because the code which reads in the tech list is
currently very strict and will include the whitespace as part of the name.
In other words, use <tech>name</tech>, not <tech> name </tech>.
More information:
https://code.google.com/p/android/issues/detail?id=65351
ProtectedPermissions
--------------------
Summary: Using system app permission
Priority: 5 / 10
Severity: Error
Category: Correctness
Permissions with the protection level signature or signatureOrSystem are only
granted to system apps. If an app is a regular non-system app, it will never
be able to use these permissions.
ValidRestrictions
-----------------
Summary: Invalid Restrictions Descriptor
Priority: 5 / 10
Severity: Fatal
Category: Correctness
Ensures that an applications restrictions XML file is properly formed
More information:
https://developer.android.com/reference/android/content/RestrictionsManager.html
VectorDrawableCompat
--------------------
Summary: Using VectorDrawableCompat
Priority: 5 / 10
Severity: Error
Category: Correctness
To use VectorDrawableCompat, you need to make two modifications to your
project. First, set android.defaultConfig.vectorDrawables.useSupportLibrary =
true in your build.gradle file, and second, use app:srcCompat instead of
android:src to refer to vector drawables.
More information:
http://chris.banes.me/2016/02/25/appcompat-vector/#enabling-the-flag
GradleIdeError
--------------
Summary: Gradle IDE Support Issues
Priority: 4 / 10
Severity: Error
Category: Correctness
Gradle is highly flexible, and there are things you can do in Gradle files
which can make it hard or impossible for IDEs to properly handle the project.
This lint check looks for constructs that potentially break IDE support.
GridLayout
----------
Summary: GridLayout validation
Priority: 4 / 10
Severity: Fatal
Category: Correctness
Declaring a layout_row or layout_column that falls outside the declared size
of a GridLayout's rowCount or columnCount is usually an unintentional error.
ObjectAnimatorBinding
---------------------
Summary: Incorrect ObjectAnimator Property
Priority: 4 / 10
Severity: Error
Category: Correctness
This check cross references properties referenced by String from
ObjectAnimator and PropertyValuesHolder method calls and ensures that the
corresponding setter methods exist and have the right signatures.
RequiredSize
------------
Summary: Missing layout_width or layout_height attributes
Priority: 4 / 10
Severity: Error
Category: Correctness
All views must specify an explicit layout_width and layout_height attribute.
There is a runtime check for this, so if you fail to specify a size, an
exception is thrown at runtime.
It's possible to specify these widths via styles as well. GridLayout, as a
special case, does not require you to specify a size.
RestrictedApi
-------------
Summary: Restricted API
Priority: 4 / 10
Severity: Error
Category: Correctness
This API has been flagged with a restriction that has not been met.
Examples of API restrictions:
* Method can only be invoked by a subclass
* Method can only be accessed from within the same library (defined by the
Gradle library group id)
.* Method can only be accessed from tests.
.
You can add your own API restrictions with the @RestrictTo annotation.
WrongCase
---------
Summary: Wrong case for view tag
Priority: 4 / 10
Severity: Fatal
Category: Correctness
Most layout tags, such as <Button>, refer to actual view classes and are
therefore capitalized. However, there are exceptions such as <fragment> and
<include>. This lint check looks for incorrect capitalizations.
More information:
http://developer.android.com/guide/components/fragments.html
LocalSuppress
-------------
Summary: @SuppressLint on invalid element
Priority: 3 / 10
Severity: Error
Category: Correctness
The @SuppressAnnotation is used to suppress Lint warnings in Java files.
However, while many lint checks analyzes the Java source code, where they can
find annotations on (for example) local variables, some checks are analyzing
the .class files. And in class files, annotations only appear on classes,
fields and methods. Annotations placed on local variables disappear. If you
attempt to suppress a lint error for a class-file based lint check, the
suppress annotation not work. You must move the annotation out to the
surrounding method.
ParcelCreator
-------------
Summary: Missing Parcelable CREATOR field
Priority: 3 / 10
Severity: Error
Category: Correctness
According to the Parcelable interface documentation, "Classes implementing the
Parcelable interface must also have a static field called CREATOR, which is an
object implementing the Parcelable.Creator interface."
More information:
http://developer.android.com/reference/android/os/Parcelable.html
UniqueConstants
---------------
Summary: Overlapping Enumeration Constants
Priority: 3 / 10
Severity: Error
Category: Correctness
The @IntDef annotation allows you to create a light-weight "enum" or type
definition. However, it's possible to accidentally specify the same value for
two or more of the values, which can lead to hard-to-detect bugs. This check
looks for this scenario and flags any repeated constants.
In some cases, the repeated constant is intentional (for example, renaming a
constant to a more intuitive name, and leaving the old name in place for
compatibility purposes.) In that case, simply suppress this check by adding a
@SuppressLint("UniqueConstants") annotation.
AccidentalOctal
---------------
Summary: Accidental Octal
Priority: 2 / 10
Severity: Error
Category: Correctness
In Groovy, an integer literal that starts with a leading 0 will be interpreted
as an octal number. That is usually (always?) an accident and can lead to
subtle bugs, for example when used in the versionCode of an app.
MangledCRLF
-----------
Summary: Mangled file line endings
Priority: 2 / 10
Severity: Error
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable MangledCRLF
On Windows, line endings are typically recorded as carriage return plus
newline: \r\n.
This detector looks for invalid line endings with repeated carriage return
characters (without newlines). Previous versions of the ADT plugin could
accidentally introduce these into the file, and when editing the file, the
editor could produce confusing visual artifacts.
More information:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375421
Orientation
-----------
Summary: Missing explicit orientation
Priority: 2 / 10
Severity: Error
Category: Correctness
The default orientation of a LinearLayout is horizontal. It's pretty easy to
believe that the layout is vertical, add multiple children to it, and wonder
why only the first child is visible (when the subsequent children are off
screen to the right). This lint rule helps pinpoint this issue by warning
whenever a LinearLayout is used with an implicit orientation and multiple
children.
It also checks for empty LinearLayouts without an orientation attribute that
also defines an id attribute. This catches the scenarios where children will
be added to the LinearLayout dynamically.
SupportAnnotationUsage
----------------------
Summary: Incorrect support annotation usage
Priority: 2 / 10
Severity: Error
Category: Correctness
This lint check makes sure that the support annotations (such as @IntDef and
@ColorInt) are used correctly. For example, it's an error to specify an
@IntRange where the from value is higher than the to value.
Correctness:Messages
====================
StringFormatInvalid
-------------------
Summary: Invalid format string
Priority: 9 / 10
Severity: Error
Category: Correctness:Messages
If a string contains a '%' character, then the string may be a formatting
string which will be passed to String.format from Java code to replace each
'%' occurrence with specific values.
This lint warning checks for two related problems:
(1) Formatting strings that are invalid, meaning that String.format will throw
exceptions at runtime when attempting to use the format string.
(2) Strings containing '%' that are not formatting strings getting passed to a
String.format call. In this case the '%' will need to be escaped as '%%'.
NOTE: Not all Strings which look like formatting strings are intended for use
by String.format; for example, they may contain date formats intended for
android.text.format.Time#format(). Lint cannot always figure out that a String
is a date format, so you may get false warnings in those scenarios. See the
suppress help topic for information on how to suppress errors in that case.
StringFormatMatches
-------------------
Summary: String.format string doesn't match the XML format string
Priority: 9 / 10
Severity: Error
Category: Correctness:Messages
This lint check ensures the following:
(1) If there are multiple translations of the format string, then all
translations use the same type for the same numbered arguments
(2) The usage of the format string in Java is consistent with the format
string, meaning that the parameter types passed to String.format matches those
in the format string.
MissingQuantity
---------------
Summary: Missing quantity translation
Priority: 8 / 10
Severity: Error
Category: Correctness:Messages
Different languages have different rules for grammatical agreement with
quantity. In English, for example, the quantity 1 is a special case. We write
"1 book", but for any other quantity we'd write "n books". This distinction
between singular and plural is very common, but other languages make finer
distinctions.
This lint check looks at each translation of a <plural> and makes sure that
all the quantity strings considered by the given language are provided by this
translation.
For example, an English translation must provide a string for quantity="one".
Similarly, a Czech translation must provide a string for quantity="few".
More information:
http://developer.android.com/guide/topics/resources/string-resource.html#Plurals
MissingTranslation
------------------
Summary: Incomplete translation
Priority: 8 / 10
Severity: Fatal
Category: Correctness:Messages
If an application has more than one locale, then all the strings declared in
one language should also be translated in all other languages.
If the string should not be translated, you can add the attribute
translatable="false" on the <string> element, or you can define all your
non-translatable strings in a resource file called donottranslate.xml. Or, you
can ignore the issue with a tools:ignore="MissingTranslation" attribute.
By default this detector allows regions of a language to just provide a subset
of the strings and fall back to the standard language strings. You can require
all regions to provide a full translation by setting the environment variable
ANDROID_LINT_COMPLETE_REGIONS.
You can tell lint (and other tools) which language is the default language in
your res/values/ folder by specifying tools:locale="languageCode" for the root
<resources> element in your resource file. (The tools prefix refers to the
namespace declaration http://schemas.android.com/tools.)
ExtraTranslation
----------------
Summary: Extra translation
Priority: 6 / 10
Severity: Fatal
Category: Correctness:Messages
If a string appears in a specific language translation file, but there is no
corresponding string in the default locale, then this string is probably
unused. (It's technically possible that your application is only intended to
run in a specific locale, but it's still a good idea to provide a fallback.).
Note that these strings can lead to crashes if the string is looked up on any
locale not providing a translation, so it's important to clean them up.
ImpliedQuantity
---------------
Summary: Implied Quantities
Priority: 5 / 10
Severity: Error
Category: Correctness:Messages
Plural strings should generally include a %s or %d formatting argument. In
locales like English, the one quantity only applies to a single value, 1, but
that's not true everywhere. For example, in Slovene, the one quantity will
apply to 1, 101, 201, 301, and so on. Similarly, there are locales where
multiple values match the zero and two quantities.
In these locales, it is usually an error to have a message which does not
include a formatting argument (such as '%d'), since it will not be clear from
the grammar what quantity the quantity string is describing.
More information:
http://developer.android.com/guide/topics/resources/string-resource.html#Plurals
JavascriptInterface
-------------------
Summary: Missing @JavascriptInterface on methods
Priority: 8 / 10
Severity: Error
Category: Security
As of API 17, you must annotate methods in objects registered with the
addJavascriptInterface method with a @JavascriptInterface annotation.
More information:
http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object, java.lang.String)
PackagedPrivateKey
------------------
Summary: Packaged private key
Priority: 8 / 10
Severity: Fatal
Category: Security
In general, you should not package private key files inside your app.
WrongConstant
-------------
Summary: Incorrect constant
Priority: 6 / 10
Severity: Error
Category: Security
Ensures that when parameter in a method only allows a specific set of
constants, calls obey those rules.
HardcodedDebugMode
------------------
Summary: Hardcoded value of android:debuggable in the manifest
Priority: 5 / 10
Severity: Fatal
Category: Security
It's best to leave out the android:debuggable attribute from the manifest. If
you do, then the tools will automatically insert android:debuggable=true when
building an APK to debug on an emulator or device. And when you perform a
release build, such as Exporting APK, it will automatically set it to false.
If on the other hand you specify a specific value in the manifest file, then
the tools will always use it. This can lead to accidentally publishing your
app with debug information.
InvalidPermission
-----------------
Summary: Invalid Permission Attribute
Priority: 5 / 10
Severity: Error
Category: Security
Not all elements support the permission attribute. If a permission is set on
an invalid element, it is a no-op and ignored. Ensure that this permission
attribute was set on the correct element to protect the correct component.
WearableBindListener
--------------------
Summary: Usage of Android Wear BIND_LISTENER is deprecated
Priority: 6 / 10
Severity: Fatal
Category: Performance
BIND_LISTENER receives all Android Wear events whether the application needs
them or not. This can be inefficient and cause applications to wake up
unnecessarily. With Google Play Services 8.2.0 or later it is recommended to
use a more efficient combination of manifest listeners and api-based live
listeners filtered by action, path and/or path prefix.
More information:
http://tools.android.com/tech-docs/bind-listener
GoogleAppIndexingUrlError
-------------------------
Summary: URL not supported by app for Firebase App Indexing
Priority: 5 / 10
Severity: Error
Category: Usability
Ensure the URL is supported by your app, to get installs and traffic to your
app from Google Search.
More information:
https://g.co/AppIndexing/AndroidStudio
MenuTitle
---------
Summary: Missing menu title
Priority: 5 / 10
Severity: Error
Category: Usability
From the action bar documentation:
"It's important that you always define android:title for each menu item — even
if you don't declare that the title appear with the action item — for three
reasons:
* If there's not enough room in the action bar for the action item, the menu
item appears in the overflow menu and only the title appears.
* Screen readers for sight-impaired users read the menu item's title.
* If the action item appears with only the icon, a user can long-press the
item to reveal a tool-tip that displays the action item's title.
The android:icon is always optional, but recommended.
More information:
http://developer.android.com/guide/topics/ui/actionbar.html
Internationalization
====================
ByteOrderMark
-------------
Summary: Byte order mark inside files
Priority: 8 / 10
Severity: Fatal
Category: Internationalization
Lint will flag any byte-order-mark (BOM) characters it finds in the middle of
a file. Since we expect files to be encoded with UTF-8 (see the EnforceUTF8
issue), the BOM characters are not necessary, and they are not handled
correctly by all tools. For example, if you have a BOM as part of a resource
name in one particular translation, that name will not be considered identical
to the base resource's name and the translation will not be used.
More information:
http://en.wikipedia.org/wiki/Byte_order_mark
EnforceUTF8
-----------
Summary: Encoding used in resource files is not UTF-8
Priority: 5 / 10
Severity: Fatal
Category: Internationalization
XML supports encoding in a wide variety of character sets. However, not all
tools handle the XML encoding attribute correctly, and nearly all Android apps
use UTF-8, so by using UTF-8 you can protect yourself against subtle bugs when
using non-ASCII characters.
In particular, the Android Gradle build system will merge resource XML files
assuming the resource files are using UTF-8 encoding.
Internationalization:Bidirectional Text
=======================================
RtlCompat
---------
Summary: Right-to-left text compatibility issues
Priority: 6 / 10
Severity: Error
Category: Internationalization:Bidirectional Text
API 17 adds a textAlignment attribute to specify text alignment. However, if
you are supporting older versions than API 17, you must also specify a gravity
or layout_gravity attribute, since older platforms will ignore the
textAlignment attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment