Lint Report

Check performed at Fri Mar 21 14:27:46 CET 2014.
3 errors and 12 warnings found:

Correctness
3Error NewApi: Calling new methods on older versions
1Warning OldTargetApi: Target SDK attribute is not targeting latest version
1Warning MissingId: Fragments should specify an id or tag
Security
1Warning AllowBackup: Missing allowBackup attribute
Performance
1Warning UseValueOf: Should use valueOf instead of new
2Warning UnusedResources: Unused resources
Internationalization
6Warning HardcodedText: Hardcoded text
Disabled Checks (11)

Correctness
NewApi: Calling new methods on older versions
src/com/example/dialogs_demo/MyActivity.java:70: Call requires API level 9 (current min is 8): java.lang.String#isEmpty
  67             }
  68         });
  69 
  70         Log.d(MyActivity.class.getSimpleName(), String.valueOf("aaa".isEmpty()));
  71     }
  72 
src/com/example/dialogs_demo/MyApplication.java:28: Call requires API level 11 (current min is 9): android.os.StrictMode.VmPolicy.Builder#detectLeakedClosableObjects
  25 //                    .penaltyDeath()
  26                     .penaltyLog();
  27             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  28                 vmBuilder.detectLeakedClosableObjects();
  29                 vmBuilder.detectActivityLeaks();    // problematic
  30             }
src/com/example/dialogs_demo/MyApplication.java:29: Call requires API level 11 (current min is 9): android.os.StrictMode.VmPolicy.Builder#detectActivityLeaks
  26                     .penaltyLog();
  27             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  28                 vmBuilder.detectLeakedClosableObjects();
  29                 vmBuilder.detectActivityLeaks();    // problematic
  30             }
  31             StrictMode.setVmPolicy(vmBuilder.build());
Note: This issue has an associated quickfix operation in Eclipse/ADT Fix
Priority: 6 / 10
Category: Correctness
Severity: Error
Explanation: Finds API accesses to APIs that are not supported in all targeted API versions.
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 AndroidManifest.xml file.
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-v11 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.

More info:

To suppress this error, use the issue id "NewApi" as explained in the Suppressing Warnings and Errors section.
OldTargetApi: Target SDK attribute is not targeting latest version
AndroidManifest.xml:7: 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.
   4           android:versionCode="1"
   5           android:versionName="1.0">
   6 
   7     <uses-sdk
   8             android:minSdkVersion="8"
   9             android:targetSdkVersion="16"/>
Priority: 6 / 10
Category: Correctness
Severity: Warning
Explanation: Checks that the manifest specifies a targetSdkVersion that is recent.
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 info: 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.
MissingId: Fragments should specify an id or tag
res/layout/another.xml:16: This <fragment> tag should specify an id or a tag to preserve state across activity restarts
  13             tools:text="Tlacitko"
  14             tools:visibility="visible"/>
  15 
  16     <fragment
  17             android:layout_width="match_parent"
  18             android:layout_height="match_parent"
Note: This issue has an associated quickfix operation in Eclipse/ADT Fix
Priority: 5 / 10
Category: Correctness
Severity: Warning
Explanation: Ensures that XML tags like <fragment> specify an id or tag attribute.
If you do not specify an android:id or an android:tag attribute on a <fragment> 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 info: http://developer.android.com/guide/components/fragments.html

To suppress this error, use the issue id "MissingId" as explained in the Suppressing Warnings and Errors section.
Security
AllowBackup: Missing allowBackup attribute
AndroidManifest.xml:10: 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)
   7     <uses-sdk
   8             android:minSdkVersion="8"
   9             android:targetSdkVersion="16"/>
  10     <application
  11             android:label="@string/app_name"
  12             android:icon="@drawable/ic_launcher"
Note: This issue has an associated quickfix operation in Eclipse/ADT Fix
Priority: 3 / 10
Category: Security
Severity: Warning
Explanation: Ensure that allowBackup is explicitly set in the application's manifest.
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)"

More info: http://developer.android.com/reference/android/R.attr.html#allowBackup

To suppress this error, use the issue id "AllowBackup" as explained in the Suppressing Warnings and Errors section.
Performance
UseValueOf: Should use valueOf instead of new
src/com/example/dialogs_demo/MyActivity.java:63: Use Integer.valueOf(5) instead
  60                     Class cls = Class.forName("PassingCounter");
  61                     Object o = cls.newInstance();
  62                     Method m = cls.getMethod("count", Integer.TYPE);
  63                     m.invoke(o, new Integer(5));
  64                 } catch (Exception e) {
  65                     Log.e(MyActivity.class.getSimpleName(), "Failed to count", e);
Priority: 4 / 10
Category: Performance
Severity: Warning
Explanation: Looks for usages of new for wrapper classes which should use valueOf instead.
You should not call the constructor for wrapper classes directly, such as`new Integer(42)`. Instead, call the valueOf factory method, such as Integer.valueOf(42). This will typically use less memory because common integers such as 0 and 1 will share a single instance.

More info:

To suppress this error, use the issue id "UseValueOf" as explained in the Suppressing Warnings and Errors section.
UnusedResources: Unused resources
res/layout/item.xml: The resource R.layout.item appears to be unused
res/layout/unused.xml: The resource R.layout.unused appears to be unused
Priority: 3 / 10
Category: Performance
Severity: Warning
Explanation: Looks for 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.
Internationalization
HardcodedText: Hardcoded text
res/layout/fragment_layout.xml:8: [I18N] Hardcoded string "fragment", should use @string resource
   5               android:layout_width="match_parent"
   6               android:layout_height="match_parent">
   7 
   8     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="fragment"/>
   9 </LinearLayout>

res/layout/item.xml:7: [I18N] Hardcoded string "item", should use @string resource
   4               android:orientation="vertical"
   5               android:layout_width="match_parent"
   6               android:layout_height="wrap_content"
   7         android:text="item" />

res/layout/main.xml:12: [I18N] Hardcoded string "Hello World, MyActivity", should use @string resource
   9     <TextView
  10             android:layout_width="fill_parent"
  11             android:layout_height="wrap_content"
  12             android:text="Hello World, MyActivity"
  13             />
  14     <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
res/layout/main.xml:16: [I18N] Hardcoded string "dialog - the old way", should use @string resource
  13             />
  14     <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
  15             android:id="@+id/btnOld"
  16             android:text="dialog - the old way"/>
  17     <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
  18             android:id="@+id/btnNew"
res/layout/main.xml:19: [I18N] Hardcoded string "dialog - styled dialogs", should use @string resource
  16             android:text="dialog - the old way"/>
  17     <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
  18             android:id="@+id/btnNew"
  19             android:text="dialog - styled dialogs"/>
  20     <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
  21             android:id="@+id/btnCounter"
res/layout/main.xml:22: [I18N] Hardcoded string "Crash", should use @string resource
  19             android:text="dialog - styled dialogs"/>
  20     <Button android:layout_width="wrap_content" android:layout_height="wrap_content"
  21             android:id="@+id/btnCounter"
  22             android:text="Crash"/>
  23 </LinearLayout>
  24 
Note: This issue has an associated quickfix operation in Eclipse/ADT Fix
Priority: 5 / 10
Category: Internationalization
Severity: Warning
Explanation: Looks for hardcoded text attributes which should be converted to resource lookup.
Hardcoding text attributes directly in layout files is bad for several reasons:

* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)

* The application cannot be translated to other languages by just adding new translations for existing string resources.

In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.

More info:

To suppress this error, use the issue id "HardcodedText" as explained in the Suppressing Warnings and Errors section.
Disabled Checks
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.

BackButton
Disabled By: Default
Priority: 6 / 10
Category: Usability
Severity: Warning
Explanation: Looks for Back buttons, which are not common on the Android platform.
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.

More info: http://developer.android.com/design/patterns/pure-android.html

To suppress this error, use the issue id "BackButton" as explained in the Suppressing Warnings and Errors section.
EasterEgg
Disabled By: Default
Priority: 6 / 10
Category: Security
Severity: Warning
Explanation: Looks for hidden easter eggs.
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.
FieldGetter
Disabled By: Default
Priority: 4 / 10
Category: Performance
Severity: Warning
Explanation: Suggests replacing uses of getters with direct field access within a class.
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.

More info: http://developer.android.com/guide/practices/design/performance.html#internal_get_set

To suppress this error, use the issue id "FieldGetter" as explained in the Suppressing Warnings and Errors section.
IconExpectedSize
Disabled By: Default
Priority: 5 / 10
Category: Usability:Icons
Severity: Warning
Explanation: Ensures that launcher icons, notification icons etc have the correct 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.

More info: http://developer.android.com/design/style/iconography.html

To suppress this error, use the issue id "IconExpectedSize" as explained in the Suppressing Warnings and Errors section.
RtlCompat
Disabled By: Default
Priority: 6 / 10
Category: Bi-directional Text
Severity: Error
Explanation: Looks for compatibility issues with RTL support.
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.

More info:

To suppress this error, use the issue id "RtlCompat" as explained in the Suppressing Warnings and Errors section.
RtlEnabled
Disabled By: Default
Priority: 3 / 10
Category: Bi-directional Text
Severity: Warning
Explanation: Looks for usages of right-to-left text constants without enabling RTL support.
To enable right-to-left support, when running on API 17 and higher, you must set the android:supportsRtl attribute in the manifest <application> element.
If you have started adding RTL attributes, but have not yet finished the migration, you can set the attribute to false to satisfy this lint check.

More info:

To suppress this error, use the issue id "RtlEnabled" as explained in the Suppressing Warnings and Errors section.
RtlHardcoded
Disabled By: Default
Priority: 5 / 10
Category: Bi-directional Text
Severity: Warning
Explanation: Looks for hardcoded left/right constants which could be start/end for bidirectional text.
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.
SelectableText
Disabled By: Default
Priority: 7 / 10
Category: Usability
Severity: Warning
Explanation: Looks for TextViews which should probably allow their text to be selected.
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.
StopShip
Disabled By: Default
Priority: 10 / 10
Category: Correctness
Severity: Warning
Explanation: Looks for comment markers of the form //STOPSHIP which indicates that code should not be released yet.
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.
TypographyQuotes
Note: This issue has an associated quickfix operation in Eclipse/ADT Fix
Disabled By: Default
Priority: 5 / 10
Category: Usability:Typography
Severity: Warning
Explanation: Looks for straight quotes which can be replaced by 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.)

More info: http://en.wikipedia.org/wiki/Quotation_mark

To suppress this error, use the issue id "TypographyQuotes" as explained in the Suppressing Warnings and Errors section.
UnusedIds
Disabled By: Default
Priority: 1 / 10
Category: Performance
Severity: Warning
Explanation: Looks for unused id's.
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"