Lint Report
Check performed at Wed Apr 22 15:29:47 PDT 2015.
0 errors and 12 warnings found:
../../build.gradle:13:
Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details.
10
11 defaultConfig {
12 minSdkVersion 9
13 targetSdkVersion 20
14 }
15
Severity:
Warning
Explanation: Target SDK attribute is not targeting latest version.
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
To suppress this error, use the issue id "OldTargetApi" as explained in the
Suppressing Warnings and Errors section.
../../src/com/facebook/samples/NativeAdSample/NativeAdListActivity.java:115:
Avoid passing null
as the view root (needed to resolve layout parameters on the inflated layout's root element)
112 this.notifyDataSetChanged();
113 }
114 this.ad = ad;
115 View adView = inflater.inflate(R.layout.ad_unit, null);
116 NativeAdSampleActivity.inflateAd(ad, adView, NativeAdListActivity.this);
117 list.add(AD_INDEX, adView);
Priority: 5 / 10
Category: Correctness
Severity:
Warning
Explanation: Layout Inflation without a Parent.
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.
To suppress this error, use the issue id "InflateParams" as explained in the
Suppressing Warnings and Errors section.
../../AndroidManifest.xml:6:
This minSdkVersion
value (9
) is not used; it is always overridden by the value specified in the Gradle build script (9
)
3 package="com.facebook.samples.NativeAdSample"
4 android:versionCode="1"
5 android:versionName="1.0">
6 <uses-sdk android:minSdkVersion="9"/>
7 <uses-permission android:name="android.permission.INTERNET"/>
8 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Priority: 4 / 10
Category: Correctness
Severity:
Warning
Explanation: Value overridden by Gradle build script.
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.
More info:
To suppress this error, use the issue id "GradleOverrides" as explained in the
Suppressing Warnings and Errors section.
../../AndroidManifest.xml:9:
Should explicitly set android:allowBackup
to true
or false
(it's true
by default, and that can have some security implications for the application's data)
6 <uses-sdk android:minSdkVersion="9"/>
7 <uses-permission android:name="android.permission.INTERNET"/>
8 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
9 <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
10 <activity android:name="NativeAdSampleActivity"
11 android:label="@string/app_name">
Severity:
Warning
Explanation: Missing allowBackup
attribute.
The allowBackup attribute determines if an application's data can be backed up and restored. It is documented at
http://developer.android.com/reference/android/R.attr.html#allowBackup
By default, this flag is set to
true
. When this flag is set to
true
, application data can be backed up and restored by the user using
adb backup
and
adb restore
.
This may have security consequences for an application.
adb backup
allows users who have enabled USB debugging to copy application data off of the device. Once backed up, all application data can be read by the user.
adb restore
allows creation of application data from a source specified by the user. Following a restore, applications should not assume that the data, file permissions, and directory permissions were created by the application itself.
Setting
allowBackup="false"
opts an application out of both backup and restore.
To fix this warning, decide whether your application should support backup, and explicitly set
android:allowBackup=(true|false)"
To suppress this error, use the issue id "AllowBackup" as explained in the
Suppressing Warnings and Errors section.
../../res/layout/activity_native_ad_demo.xml:5:
Possible overdraw: Root element paints background #E4E5E8
with a theme that also paints a background (inferred theme is @android:style/Theme.Holo
)
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:background="#E4E5E8"
6 android:orientation="vertical"
7 android:weightSum="100" >
../../res/layout/ad_unit.xml:9:
Possible overdraw: Root element paints background @android:color/white
with a theme that also paints a background (inferred theme is @android:style/Theme.Holo
)
6 android:id="@+id/adUnit"
7 android:layout_width="match_parent"
8 android:layout_height="wrap_content"
9 android:background="@android:color/white"
10 android:orientation="vertical"
11 android:paddingTop="10dp" >
Priority: 3 / 10
Category: Performance
Severity:
Warning
Explanation: Overdraw: Painting regions more than once.
If you set a background drawable on a root view, then you should use a custom theme where the theme background is null. Otherwise, the theme background will be painted first, only to have your custom background completely cover it; this is called "overdraw".
NOTE: This detector relies on figuring out which layouts are associated with which activities based on scanning the Java code, and it's currently doing that using an inexact pattern matching algorithm. Therefore, it can incorrectly conclude which activity the layout is associated with and then wrongly complain that a background-theme is hidden.
If you want your custom background on multiple pages, then you should consider making a custom theme with your custom background and just using that theme instead of a root element background.
Of course it's possible that your custom drawable is translucent and you want it to be mixed with the background. However, you will get better performance if you pre-mix the background with your drawable and use that resulting image or color as a custom theme background instead.
More info:
To suppress this error, use the issue id "Overdraw" as explained in the
Suppressing Warnings and Errors section.
Priority: 3 / 10
Category: Performance
Severity:
Warning
Explanation: Unused resources.
Unused resources make applications larger and slow down builds.
More info:
To suppress this error, use the issue id "UnusedResources" as explained in the
Suppressing Warnings and Errors section.
../../res:
Missing density variation folders in res
: drawable-xxxhdpi
Priority: 3 / 10
Category: Usability:Icons
Severity:
Warning
Explanation: Missing density folder.
Icons will look best if a custom version is provided for each of the major screen density classes (low, medium, high, extra-high, extra-extra-high). This lint check identifies folders which are missing, such as
drawable-hdpi
.
Low density is not really used much anymore, so this check ignores the ldpi density. To force lint to include it, set the environment variable
ANDROID_LINT_INCLUDE_LDPI=true
. For more information on current density usage, see
http://developer.android.com/resources/dashboard/screens.html
To suppress this error, use the issue id "IconMissingDensityFolder" as explained in the
Suppressing Warnings and Errors section.
../../src/com/facebook/samples/NativeAdSample/NativeAdSampleActivity.java:131:
com/facebook/samples/NativeAdSample/NativeAdSampleActivity$3#onTouch
should call View#performClick
when a click is detected
128 // The touch listener could be used to do animations.
129 nativeAd.setOnTouchListener(new OnTouchListener() {
130 @Override
131 public boolean onTouch(View view, MotionEvent event) {
132 if (event.getAction() == MotionEvent.ACTION_DOWN) {
133 switch (view.getId()) {
Priority: 6 / 10
Category: Accessibility
Severity:
Warning
Explanation: Accessibility in Custom Views.
If a View
that overrides onTouchEvent
or uses an OnTouchListener
does not also implement performClick
and call it when clicks are detected, the View
may not handle accessibility actions properly. Logic handling the click actions should ideally be placed in View#performClick
as some accessibility services invoke performClick
when a click action should occur.
More info:
To suppress this error, use the issue id "ClickableViewAccessibility" as explained in the
Suppressing Warnings and Errors section.
../../res/layout/ad_unit.xml:30:
When you define paddingLeft
you should probably also define paddingRight
for right-to-left symmetry
27 android:orientation="vertical"
28 android:layout_width="fill_parent"
29 android:layout_height="wrap_content"
30 android:paddingLeft="5dp"
31 >
32
Priority: 6 / 10
Category: Bi-directional Text
Severity:
Warning
Explanation: Padding and margin symmetry.
If you specify padding or margin on the left side of a layout, you should probably also specify padding on the right side (and vice versa) for right-to-left layout symmetry.
More info:
To suppress this error, use the issue id "RtlSymmetry" as explained in the
Suppressing Warnings and Errors section.
../../res/layout/ad_unit.xml:30:
Consider adding android:paddingStart="5dp"
to better support right-to-left layouts
27 android:orientation="vertical"
28 android:layout_width="fill_parent"
29 android:layout_height="wrap_content"
30 android:paddingLeft="5dp"
31 >
32
../../res/layout/list_item.xml:6:
Use "start
" instead of "left
" to ensure correct behavior in right-to-left locales
3 android:layout_width="fill_parent"
4 android:layout_height="100dp"
5 android:background="@android:color/white"
6 android:gravity="left|center"
7 android:padding="10dp"
8 android:textColor="@android:color/black"
Priority: 5 / 10
Category: Bi-directional Text
Severity:
Warning
Explanation: Using left/right instead of start/end attributes.
Using Gravity#LEFT
and Gravity#RIGHT
can lead to problems when a layout is rendered in locales where text flows from right to left. Use Gravity#START
and Gravity#END
instead. Similarly, in XML gravity
and layout_gravity
attributes, use start
rather than left
.
For XML attributes such as paddingLeft and layout_marginLeft
, use paddingStart
and layout_marginStart
. NOTE: If your minSdkVersion
is less than 17, you should add both the older left/right attributes as well as the new start/right attributes. On older platforms, where RTL is not supported and the start/right attributes are unknown and therefore ignored, you need the older left/right attributes. There is a separate lint check which catches that type of error.
(Note: For Gravity#LEFT
and Gravity#START
, you can use these constants even when targeting older platforms, because the start
bitmask is a superset of the left
bitmask. Therefore, you can use gravity="start"
rather than gravity="left|start"
.)
More info:
To suppress this error, use the issue id "RtlHardcoded" as explained in the
Suppressing Warnings and Errors section.
The following issues were not run by lint, either because the check is not enabled by default, or because it was disabled with a command line flag or via one or more lint.xml configuration files in the project directories.
Disabled By: Default
Priority: 6 / 10
Category: Usability
Severity:
Warning
Explanation: Back button.
According to the Android Design Guide,
"Other platforms use an explicit back button with label to allow the user to navigate up the application's hierarchy. Instead, Android uses the main action bar's app icon for hierarchical navigation and the navigation bar's back button for temporal navigation."
This check is not very sophisticated (it just looks for buttons with the label "Back"), so it is disabled by default to not trigger on common scenarios like pairs of Back/Next buttons to paginate through screens.
To suppress this error, use the issue id "BackButton" as explained in the
Suppressing Warnings and Errors section.
Disabled By: Default
Priority: 6 / 10
Category: Security
Severity:
Warning
Explanation: Code contains easter egg.
An "easter egg" is code deliberately hidden in the code, both from potential users and even from other developers. This lint check looks for code which looks like it may be hidden from sight.
More info:
To suppress this error, use the issue id "EasterEgg" as explained in the
Suppressing Warnings and Errors section.
Disabled By: Default
Priority: 4 / 10
Category: Performance
Severity:
Warning
Explanation: Using getter instead of field.
Accessing a field within the class that defines a getter for that field is at least 3 times faster than calling the getter. For simple getters that do nothing other than return the field, you might want to just reference the local field directly instead.
NOTE: As of Android 2.3 (Gingerbread), this optimization is performed automatically by Dalvik, so there is no need to change your code; this is only relevant if you are targeting older versions of Android.
To suppress this error, use the issue id "FieldGetter" as explained in the
Suppressing Warnings and Errors section.
Disabled By: Default
Priority: 5 / 10
Category: Usability:Icons
Severity:
Warning
Explanation: Icon has incorrect size.
There are predefined sizes (for each density) for launcher icons. You should follow these conventions to make sure your icons fit in with the overall look of the platform.
To suppress this error, use the issue id "IconExpectedSize" as explained in the
Suppressing Warnings and Errors section.
Disabled By: Default
Priority: 4 / 10
Category: Usability
Severity:
Warning
Explanation: Negative Margins.
Margin values should be positive. Negative values are generally a sign that you are making assumptions about views surrounding the current one, or may be tempted to turn off child clipping to allow a view to escape its parent. Turning off child clipping to do this not only leads to poor graphical performance, it also results in wrong touch event handling since touch events are based strictly on a chain of parent-rect hit tests. Finally, making assumptions about the size of strings can lead to localization problems.
More info:
To suppress this error, use the issue id "NegativeMargin" as explained in the
Suppressing Warnings and Errors section.
Severity:
Warning
Explanation: Newer Library Versions Available.
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.
More info:
To suppress this error, use the issue id "NewerVersionAvailable" as explained in the
Suppressing Warnings and Errors section.
Severity:
Warning
Explanation: Dynamic text should probably be selectable.
If a <TextView>
is used to display data, the user might want to copy that data and paste it elsewhere. To allow this, the <TextView>
should specify android:textIsSelectable="true"
.
This lint check looks for TextViews which are likely to be displaying data: views whose text is set dynamically. This value will be ignored on platforms older than API 11, so it is okay to set it regardless of your minSdkVersion
.
More info:
To suppress this error, use the issue id "SelectableText" as explained in the
Suppressing Warnings and Errors section.
Severity:
Warning
Explanation: Code contains STOPSHIP
marker.
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.
More info:
To suppress this error, use the issue id "StopShip" as explained in the
Suppressing Warnings and Errors section.
Severity:
Warning
Explanation: Straight quotes can be replaced with curvy quotes.
Straight single quotes and double quotes, when used as a pair, can be replaced by "curvy quotes" (or directional quotes). This can make the text more readable.
Note that you should never use grave accents and apostrophes to quote, `like this'.
(Also note that you should not use curvy quotes for code fragments.)
To suppress this error, use the issue id "TypographyQuotes" as explained in the
Suppressing Warnings and Errors section.
Disabled By: Default
Priority: 1 / 10
Category: Performance
Severity:
Warning
Explanation: Unused id.
This resource id definition appears not to be needed since it is not referenced from anywhere. Having id definitions, even if unused, is not necessarily a bad idea since they make working on layouts and menus easier, so there is not a strong reason to delete these.
More info:
To suppress this error, use the issue id "UnusedIds" as explained in the
Suppressing Warnings and Errors section.
Suppressing Warnings and Errors
Lint errors can be suppressed in a variety of ways:
1. With a @SuppressLint annotation in the Java code
2. With a tools:ignore attribute in the XML file
3. With a lint.xml configuration file in the project
4. With a lint.xml configuration file passed to lint via the --config flag
5. With the --ignore flag passed to lint.
To suppress a lint warning with an annotation, add a @SuppressLint("id") annotation on the class, method or variable declaration closest to the warning instance you want to disable. The id can be one or more issue id's, such as "UnusedResources" or {"UnusedResources","UnusedIds"}, or it can be "all" to suppress all lint warnings in the given scope.
To suppress a lint warning in an XML file, add a tools:ignore="id" attribute on the element containing the error, or one of its surrounding elements. You also need to define the namespace for the tools prefix on the root element in your document, next to the xmlns:android declaration:
* xmlns:tools="http://schemas.android.com/tools"
To suppress lint warnings with a configuration XML file, create a file named lint.xml and place it at the root directory of the project in which it applies. (If you use the Eclipse plugin's Lint view, you can suppress errors there via the toolbar and Eclipse will create the lint.xml file for you.).
The format of the lint.xml file is something like the following:
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<!-- Disable this given check in this project -->
<issue id="IconMissingDensityFolder" severity="ignore" />
<!-- Ignore the ObsoleteLayoutParam issue in the given files -->
<issue id="ObsoleteLayoutParam">
<ignore path="res/layout/activation.xml" />
<ignore path="res/layout-xlarge/activation.xml" />
</issue>
<!-- Ignore the UselessLeaf issue in the given file -->
<issue id="UselessLeaf">
<ignore path="res/layout/main.xml" />
</issue>
<!-- Change the severity of hardcoded strings to "error" -->
<issue id="HardcodedText" severity="error" />
</lint>
To suppress lint checks from the command line, pass the --ignore flag with a comma separated list of ids to be suppressed, such as:
"lint --ignore UnusedResources,UselessLeaf /my/project/path"