Android Lint 检查项目列表

Correctness

AdapterViewChildren

Summary: AdapterViews cannot have children in XML

Priority: 10 / 10
Severity: Warning
Category: Correctness

AdapterViews such as ListViews must be configured with data from Java code,
such as a ListAdapter.

More information:
http://developer.android.com/reference/android/widget/AdapterView.html

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.

StopShip

Summary: Code contains STOPSHIP marker

Priority: 10 / 10
Severity: Warning
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable StopShip

Using the comment // STOPSHIP can be used to flag code that is incomplete but
checked in. This comment marker can be used to indicate that the code should
not be shipped until the issue is addressed, and lint will look for these.

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.

SuspiciousImport

Summary: 'import android.R' statement

Priority: 9 / 10
Severity: Warning
Category: Correctness

Importing android.R is usually not intentional; it sometimes happens when you
use an IDE and ask it to automatically add imports at a time when your
project's R class it not present.

Once the import is there you might get a lot of "confusing" error messages
because of course the fields available on android.R are not the ones you'd
expect from just looking at your own R class.

UsesMinSdkAttributes

Summary: Minimum SDK and target SDK attributes not defined

Priority: 9 / 10
Severity: Warning
Category: Correctness

The manifest should contain a element which defines the minimum API
Level required for the application to run, as well as the target version (the
highest API level you have tested the version for.)

More information:
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

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 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.

IllegalResourceRef

Summary: Name and version must be integer or string, not resource

Priority: 8 / 10
Severity: Warning
Category: Correctness

For the versionCode attribute, you have to specify an actual integer literal;
you cannot use an indirection with a @dimen/name resource. Similarly, the
versionName attribute should be an actual string, not a string resource url.

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
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.

ScrollViewCount

Summary: ScrollViews can have only one child

Priority: 8 / 10
Severity: Warning
Category: Correctness

ScrollViews can only have one child widget. If you want more children, wrap
them in a container layout.

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.

CommitTransaction

Summary: Missing commit() calls

Priority: 7 / 10
Severity: Warning
Category: Correctness

After creating a FragmentTransaction, you typically need to commit it as well

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.

DeviceAdmin

Summary: Malformed Device Admin

Priority: 7 / 10
Severity: Warning
Category: Correctness

If you register a broadcast receiver which acts as a device admin, you must
also register an for the action
android.app.action.DEVICE_ADMIN_ENABLED, without any , such that the
device admin can be activated/deactivated.

To do this, add



to your .

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.

InconsistentArrays

Summary: Inconsistencies in array element counts

Priority: 7 / 10
Severity: Warning
Category: Correctness

When an array is translated in a different locale, it should normally have the
same number of elements as the original array. When adding or removing
elements to an array, it is easy to forget to update all the locales, and this
lint warning finds inconsistencies like these.

Note however that there may be cases where you really want to declare a
different number of array items in each configuration (for example where the
array represents available options, and those options differ for different
layout orientations and so on), so use your own judgement to decide if this is
really an error.

You can suppress this error type if it finds false errors in your project.

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

NestedScrolling

Summary: Nested scrolling widgets

Priority: 7 / 10
Severity: Warning
Category: Correctness

A scrolling widget such as a ScrollView should not contain any nested
scrolling widgets since this has various usability issues

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.

ScrollViewSize

Summary: ScrollView size validation

Priority: 7 / 10
Severity: Warning
Category: Correctness

ScrollView children must set their layout_width or layout_height attributes to
wrap_content rather than fill_parent or match_parent in the scrolling
dimension

TextViewEdits

Summary: TextView should probably be an EditText instead

Priority: 7 / 10
Severity: Warning
Category: Correctness

Using a to input text is generally an error, you should be using
instead. EditText is a subclass of TextView, and some of the
editing support is provided by TextView, so it's possible to set some
input-related properties on a TextView. However, using a TextView along with
input attributes is usually a cut & paste error. To input text you should be
using .

This check also checks subclasses of TextView, such as Button and CheckBox,
since these have the same issue: they should not be used with editable
attributes.

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.

AppCompatMethod

Summary: Using Wrong AppCompat Method

Priority: 6 / 10
Severity: Warning
Category: Correctness

When using the appcompat library, there are some methods you should be calling
instead of the normal ones; for example, getSupportActionBar() instead of
getActionBar(). This lint check looks for calls to the wrong method.

More information:
http://developer.android.com/tools/support-library/index.html

ApplySharedPref

Summary: Use apply() on SharedPreferences

Priority: 6 / 10
Severity: Warning
Category: Correctness

Consider using apply() instead of commit on shared preferences. Whereas commit
blocks and writes its data to persistent storage immediately, apply will
handle it in the background.

Assert

Summary: Assertions

Priority: 6 / 10
Severity: Warning
Category: Correctness

Assertions are not checked at runtime. There are ways to request that they be
used by Dalvik (adb shell setprop debug.assert 1), but the property is ignored
in many places and can not be relied upon. Instead, perform conditional
checking inside if (BuildConfig.DEBUG) { } blocks. That constant is a static
final boolean which is true in debug builds and false in release builds, and
the Java compiler completely removes all code inside the if-body from the
app.

For example, you can replace assert speed > 0 with if (BuildConfig.DEBUG &&
!(speed > 0)) { throw new AssertionError() }.

(Note: This lint check does not flag assertions purely asserting nullness or
non-nullness; these are typically more intended for tools usage than runtime
checks.)

More information:
https://code.google.com/p/android/issues/detail?id=65183

CheckResult

Summary: Ignoring results

Priority: 6 / 10
Severity: Warning
Category: Correctness

Some methods have no side effects, an calling them without doing something
without the result is suspicious.

CommitPrefEdits

Summary: Missing commit() on SharedPreference editor

Priority: 6 / 10
Severity: Warning
Category: Correctness

After calling edit() on a SharedPreference, you must call commit() or apply()
on the editor to save the results.

CustomViewStyleable

Summary: Mismatched Styleable/Custom View Name

Priority: 6 / 10
Severity: Warning
Category: Correctness

The convention for custom views is to use a declare-styleable whose name
matches the custom view class name. The IDE relies on this convention such
that for example code completion can be offered for attributes in a custom
view in layout XML resource files.

(Similarly, layout parameter classes should use the suffix _Layout.)

CutPasteId

Summary: Likely cut & paste mistakes

Priority: 6 / 10
Severity: Warning
Category: Correctness

This lint check looks for cases where you have cut & pasted calls to
findViewById but have forgotten to update the R.id field. It's possible that
your code is simply (redundantly) looking up the field repeatedly, but lint
cannot distinguish that from a case where you for example want to initialize
fields prev and next and you cut & pasted findViewById(R.id.prev) and forgot
to update the second initialization to R.id.next.

DefaultLocale

Summary: Implied default locale in case conversion

Priority: 6 / 10
Severity: Warning
Category: Correctness

Calling String#toLowerCase() or #toUpperCase() without specifying an explicit
locale is a common source of bugs. The reason for that is that those methods
will use the current locale on the user's device, and even though the code
appears to work correctly when you are developing the app, it will fail in
some locales. For example, in the Turkish locale, the uppercase replacement
for i is not I.

If you want the methods to just perform ASCII replacement, for example to
convert an enum name, call String#toUpperCase(Locale.US) instead. If you
really want to use the current locale, call
String#toUpperCase(Locale.getDefault()) instead.

More information:
http://developer.android.com/reference/java/util/Locale.html#default_locale

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.

DuplicateIncludedIds

Summary: Duplicate ids across layouts combined with include tags

Priority: 6 / 10
Severity: Warning
Category: Correctness

It's okay for two independent layouts to use the same ids. However, if layouts
are combined with include tags, then the id's need to be unique within any
chain of included layouts, or Activity#findViewById() can return an unexpected
view.

GradleDeprecated

Summary: Deprecated Gradle Construct

Priority: 6 / 10
Severity: Warning
Category: Correctness

This detector looks for deprecated Gradle constructs which currently work but
will likely stop working in a future update.

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:
android:required="false"/>

More information:
https://developer.android.com/guide/topics/manifest/uses-feature-element.html

InconsistentLayout

Summary: Inconsistent Layouts

Priority: 6 / 10
Severity: Warning
Category: Correctness

This check ensures that a layout resource which is defined in multiple
resource folders, specifies the same set of widgets.

This finds cases where you have accidentally forgotten to add a widget to all
variations of the layout, which could result in a runtime crash for some
resource configurations when a findViewById() fails.

There are cases where this is intentional. For example, you may have a
dedicated large tablet layout which adds some extra widgets that are not
present in the phone version of the layout. As long as the code accessing the
layout resource is careful to handle this properly, it is valid. In that case,
you can suppress this lint check for the given extra or missing views, or the
whole layout

InlinedApi

Summary: Using inlined constants on older versions

Priority: 6 / 10
Severity: Warning
Category: Correctness

This check scans through all the Android API field references in the
application and flags certain constants, such as static final integers and
Strings, which were introduced in later versions. These will actually be
copied into the class files rather than being referenced, which means that the
value is available even when running on older devices. In some cases that's
fine, and in other cases it can result in a runtime crash or incorrect
behavior. It depends on the context, so consider the code carefully and device
whether it's safe and can be suppressed or whether the code needs tbe
guarded.

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.

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
theFirebaseAnalytics#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 element in 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.

LocaleFolder

Summary: Wrong locale name

Priority: 6 / 10
Severity: Warning
Category: Correctness

From the java.util.Locale documentation:
"Note that Java uses several deprecated two-letter codes. The Hebrew ("he")
language code is rewritten as "iw", Indonesian ("id") as "in", and Yiddish
("yi") as "ji". This rewriting happens even if you construct your own Locale
object, not just for instances returned by the various lookup methods.

Because of this, if you add your localized resources in for example values-he
they will not be used, since the system will look for values-iw instead.

To work around this, place your resources in a values folder using the
deprecated language code instead.

More information:
http://developer.android.com/reference/java/util/Locale.html

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.)

MissingBackupPin

Summary: Missing Backup Pin

Priority: 6 / 10
Severity: Warning
Category: Correctness

It is highly recommended to declare a backup element. Not having a
second pin defined can cause connection failures when the particular site
certificate is rotated and the app has not yet been updated.

More information:
https://developer.android.com/preview/features/security-config.html

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



to your or .

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
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



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 elements in the manifest

Priority: 6 / 10
Severity: Fatal
Category: Correctness

The 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 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!)

OldTargetApi

Summary: Target SDK attribute is not targeting latest version

Priority: 6 / 10
Severity: Warning
Category: Correctness

When your application runs on a version of Android that is more recent than
your targetSdkVersion specifies that it has been tested with, various
compatibility modes kick in. This ensures that your application continues to
work, but it may look out of place. For example, if the targetSdkVersion is
less than 14, your app may get an option button in the UI.

To fix this issue, set the targetSdkVersion to the highest available value.
Then test your app to make sure everything works correctly. You may want to
consult the compatibility notes to see what changes apply to each version you
are adding support for:
http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

More information:
http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

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.

PinSetExpiry

Summary: Validate expiration attribute

Priority: 6 / 10
Severity: Warning
Category: Correctness

Ensures that the expiration attribute of the element is valid and
has not already expired or is expiring soon

More information:
https://developer.android.com/preview/features/security-config.html

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.

Registered

Summary: Class is not registered in the manifest

Priority: 6 / 10
Severity: Warning
Category: Correctness

Activities, services and content providers should be registered in the
AndroidManifest.xml file using , and tags.

If your activity is simply a parent class intended to be subclassed by other
"real" activities, make it an abstract class.

More information:
http://developer.android.com/guide/topics/manifest/manifest-intro.html

SdCardPath

Summary: Hardcoded reference to /sdcard

Priority: 6 / 10
Severity: Warning
Category: Correctness

Your code should not reference the /sdcard path directly; instead use
Environment.getExternalStorageDirectory().getPath().

Similarly, do not reference the /data/data/ path directly; it can vary in
multi-user scenarios. Instead, use Context.getFilesDir().getPath().

More information:
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

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.

ShortAlarm

Summary: Short or Frequent Alarm

Priority: 6 / 10
Severity: Warning
Category: Correctness

Frequent alarms are bad for battery life. As of API 22, the AlarmManager will
override near-future and high-frequency alarm requests, delaying the alarm at
least 5 seconds into the future and ensuring that the repeat interval is at
least 60 seconds.

If you really need to do work sooner than 5 seconds, post a delayed message or
runnable to a Handler.

ShowToast

Summary: Toast created but not shown

Priority: 6 / 10
Severity: Warning
Category: Correctness

Toast.makeText() creates a Toast but does not show it. You must call show() on
the resulting object to actually make the Toast appear.

SimpleDateFormat

Summary: Implied locale in date format

Priority: 6 / 10
Severity: Warning
Category: Correctness

Almost all callers should use getDateInstance(), getDateTimeInstance(), or
getTimeInstance() to get a ready-made instance of SimpleDateFormat suitable
for the user's locale. The main reason you'd create an instance this class
directly is because you need to format/parse a specific machine-readable
format, in which case you almost certainly want to explicitly ask for US to
ensure that you get ASCII digits (rather than, say, Arabic digits).

Therefore, you should either use the form of the SimpleDateFormat constructor
where you pass in an explicit locale, such as Locale.US, or use one of the get
instance methods, or suppress this error if really know what you are doing.

More information:
http://developer.android.com/reference/java/text/SimpleDateFormat.html

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 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

UnusedAttribute

Summary: Attribute unused on older versions

Priority: 6 / 10
Severity: Warning
Category: Correctness

This check finds attributes set in XML files that were introduced in a version
newer than the oldest version targeted by your application (with the
minSdkVersion attribute).

This is not an error; the application will simply ignore the attribute.
However, if the attribute is important to the appearance of functionality of
your application, you should consider finding an alternative way to achieve
the same result with only available attributes, and then you can optionally
create a copy of the layout in a layout-vNN folder which will be used on API
NN or higher where you can take advantage of the newer attribute.

Note: This check does not only apply to attributes. For example, some tags can
be unused too, such as the new element in layouts introduced in API 21.

UseAlpha2

Summary: Using 3-letter Codes

Priority: 6 / 10
Severity: Warning
Category: Correctness

For compatibility with earlier devices, you should only use 3-letter language
and region codes when there is no corresponding 2 letter code.

More information:
https://tools.ietf.org/html/bcp47

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(...).

WifiManagerPotentialLeak

Summary: WifiManager Potential Leak

Priority: 6 / 10
Severity: Warning
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.

In many cases, it's not obvious from the code where the Context is coming from
(e.g. it might be a parameter to a method, or a field initialized from various
method calls.) It's possible that the context being passed in is the
application context, but to be on the safe side, you should consider changing
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 element should be defined as a direct child of the
tag, not the tag or an tag. Similarly, a
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

WrongRegion

Summary: Suspicious Language/Region Combination

Priority: 6 / 10
Severity: Warning
Category: Correctness

Android uses the letter codes ISO 639-1 for languages, and the letter codes
ISO 3166-1 for the region codes. In many cases, the language code and the
country where the language is spoken is the same, but it is also often not the
case. For example, while 'se' refers to Sweden, where Swedish is spoken, the
language code for Swedish is not se (which refers to the Northern Sami
language), the language code is sv. And similarly the region code for sv is El
Salvador.

This lint check looks for suspicious language and region combinations, to help
catch cases where you've accidentally used the wrong language or region code.
Lint knows about the most common regions where a language is spoken, and if a
folder combination is not one of these, it is flagged as suspicious.

Note however that it may not be an error: you can theoretically have speakers
of any language in any region and want to target that with your resources, so
this check is aimed at tracking down likely mistakes, not to enforce a
specific set of region and language combinations.

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

AppLinksAutoVerifyWarning

Summary: Potential App Links Auto Verification Failure

Priority: 5 / 10
Severity: Warning
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable AppLinksAutoVerifyWarning

Ensures that app links are correctly set and associated with website.

More information:
https://g.co/appindexing/applinks

BatteryLife

Summary: Battery Life Issues

Priority: 5 / 10
Severity: Warning
Category: Correctness

This issue flags code that either

  • negatively affects battery life, or
  • uses APIs that have recently changed behavior to prevent background tasks
    from consuming memory and battery excessively.

Generally, you should be using JobScheduler or GcmNetworkManager instead.

For more details on how to update your code, please
seehttp://developer.android.com/preview/features/background-optimization.html

More information:
http://developer.android.com/preview/features/background-optimization.html

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.

DuplicateUsesFeature

Summary: Feature declared more than once

Priority: 5 / 10
Severity: Warning
Category: Correctness

A given feature should only be declared once in the manifest.

FullBackupContent

Summary: Valid Full Backup Content File

Priority: 5 / 10
Severity: Fatal
Category: Correctness

Ensures that a 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 tag will only be used if you also
override layout_width and layout_height on the tag; otherwise they
will be ignored.

More information:
http://stackoverflow.com/questions/2631614/does-android-xml-layouts-include-tag-really-work

InflateParams

Summary: Layout Inflation without a Parent

Priority: 5 / 10
Severity: Warning
Category: Correctness

When inflating a layout, avoid passing in null as the parent view, since
otherwise any layout parameters on the root of the inflated layout will be
ignored.

More information:
http://www.doubleencore.com/2013/05/layout-inflation-as-intended

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.

ManifestOrder

Summary: Incorrect order of elements in manifest

Priority: 5 / 10
Severity: Warning
Category: Correctness

The tag should appear after the elements which declare which
version you need, which features you need, which libraries you need, and so
on. In the past there have been subtle bugs (such as themes not getting
applied correctly) when the tag appears before some of these
other elements, so it's best to order your manifest in the logical dependency
order.

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.

MissingId

Summary: Fragments should specify an id or tag

Priority: 5 / 10
Severity: Warning
Category: Correctness

If you do not specify an android:id or an android:tag attribute on a
element, then if the activity is restarted (for example for an
orientation rotation) you may lose state. From the fragment documentation:

"Each fragment requires a unique identifier that the system can use to restore
the fragment if the activity is restarted (and which you can use to capture
the fragment to perform transactions, such as remove it).

  • Supply the android:id attribute with a unique ID.
  • Supply the android:tag attribute with a unique string.
    If you provide neither of the previous two, the system uses the ID of the
    container view.

More information:
http://developer.android.com/guide/components/fragments.html

NetworkSecurityConfig

Summary: Valid Network Security Config File

Priority: 5 / 10
Severity: Fatal
Category: Correctness

Ensures that a 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 , there can be whitespace around the 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 name, not name .

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.

SQLiteString

Summary: Using STRING instead of TEXT

Priority: 5 / 10
Severity: Warning
Category: Correctness

In SQLite, any column can store any data type; the declared type for a column
is more of a hint as to what the data should be cast to when stored.

There are many ways to store a string. TEXT, VARCHAR, CHARACTER and CLOB are
string types, but STRING is not. Columns defined as STRING are actually
numeric.

If you try to store a value in a numeric column, SQLite will try to cast it to
a float or an integer before storing. If it can't, it will just store it as a
string.

This can lead to some subtle bugs. For example, when SQLite encounters a
string like 1234567e1234, it will parse it as a float, but the result will be
out of range for floating point numbers, so Inf will be stored! Similarly,
strings that look like integers will lose leading zeroes.

To fix this, you can change your schema to use a TEXT type instead.

More information:
https://www.sqlite.org/datatype3.html

StateListReachable

Summary: Unreachable state in a

Priority: 5 / 10
Severity: Warning
Category: Correctness

In a selector, only the last child in the state list should omit a state
qualifier. If not, all subsequent items in the list will be ignored since the
given item will match all.

UnknownIdInLayout

Summary: Reference to an id that is not in the current layout

Priority: 5 / 10
Severity: Warning
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 is sometimes intentional, for example where you are referring to a view
which is provided in a different layout via an include. However, it is usually
an accident where you have a typo or you have renamed a view without updating
all the references to it.

UnlocalizedSms

Summary: SMS phone number missing country code

Priority: 5 / 10
Severity: Warning
Category: Correctness

SMS destination numbers must start with a country code or the application code
must ensure that the SMS is only sent when the user is in the same country as
the receiver.

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

VectorRaster

Summary: Vector Image Generation

Priority: 5 / 10
Severity: Warning
Category: Correctness

Vector icons require API 21, but when using Android Gradle plugin 1.4 or
higher, vectors placed in the drawable folder are automatically moved to
drawable-dpi-v21 and a bitmap image is generated each drawable-dpi folder
instead, for backwards compatibility (provided minSdkVersion is less than
21.).

However, there are some limitations to this vector image generation, and this
lint check flags elements and attributes that are not fully supported. You
should manually check whether the generated output is acceptable for those
older devices.

GradleDependency

Summary: Obsolete Gradle Dependency

Priority: 4 / 10
Severity: Warning
Category: Correctness

This detector looks for usages of libraries where the version you are using is
not the current stable release. Using older versions is fine, and there are
cases where you deliberately want to stick with an older version. However, you
may simply not be aware that a more recent version is available, and that is
what this lint check helps find.

GradleDynamicVersion

Summary: Gradle Dynamic Version

Priority: 4 / 10
Severity: Warning
Category: Correctness

Using + in dependencies lets you automatically pick up the latest available
version rather than a specific, named version. However, this is not
recommended; your builds are not repeatable; you may have tested with a
slightly different version than what the build server used. (Using a dynamic
version as the major version number is more problematic than using it in the
minor version position.)

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.

GradleOverrides

Summary: Value overridden by Gradle build script

Priority: 4 / 10
Severity: Warning
Category: Correctness

The value of (for example) minSdkVersion is only used if it is not specified
in the build.gradle build scripts. When specified in the Gradle build scripts,
the manifest value is ignored and can be misleading, so should be removed to
avoid ambiguity.

GradlePath

Summary: Gradle Path Issues

Priority: 4 / 10
Severity: Warning
Category: Correctness

Gradle build scripts are meant to be cross platform, so file paths use
Unix-style path separators (a forward slash) rather than Windows path
separators (a backslash). Similarly, to keep projects portable and repeatable,
avoid using absolute paths on the system; keep files within the project
instead. To share code between projects, consider creating an android-library
and an AAR dependency

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.

InOrMmUsage

Summary: Using mm or in dimensions

Priority: 4 / 10
Severity: Warning
Category: Correctness

Avoid using mm (millimeters) or in (inches) as the unit for dimensions.

While it should work in principle, unfortunately many devices do not report
the correct true physical density, which means that the dimension calculations
won't work correctly. You are better off using dp (and for font sizes, sp.)

NewerVersionAvailable

Summary: Newer Library Versions Available

Priority: 4 / 10
Severity: Warning
Category: Correctness
NOTE: This issue is disabled by default!
You can enable it by adding --enable NewerVersionAvailable

This detector checks with a central repository to see if there are newer
versions available for the dependencies used by this project. This is similar
to the GradleDependency check, which checks for newer versions available in
the Android SDK tools and libraries, but this works with any MavenCentral
dependency, and connects to the library every time, which makes it more
flexible but also much slower.

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.

VisibleForTests

Summary: Visible Only For Tests

Priority: 4 / 10
Severity: Warning
Category: Correctness

With the @VisibleForTesting annotation you can specify an otherwise= attribute
which specifies the intended visibility if the method had not been made more
widely visible for the tests.

This check looks for accesses from production code (e.g. not tests) where the
access would not have been allowed with the intended production visibility.

WrongCase

Summary: Wrong case for view tag

Priority: 4 / 10
Severity: Fatal
Category: Correctness

Most layout tags, such as

你可能感兴趣的:(Android Lint 检查项目列表)