ANDROID.NPE

A NullPointerException is thrown in case of an attempt to dereference a null value. The dereference may be a function call, a read or write of a field, or an array access. An ANDROID.NPE error is reported for Android-specific null pointer dereference situations.

Example 1

Copy
     protected void onCreate(Bundle bundle) {
         super.onCreate(bundle);
         setContentView(R.layout.note_layout);
         final ImageView image = (ImageView) findViewById(R.id.image);
 
         final String title = bundle.getString(TITLE);
         setTitle(title);
     }

ANDROID.NPE is reported for line 22 since 'bundle' might be null in the 'onCreate()' method due to the contract.

Security training

Application security training materials provided by Secure Code Warrior.

Extension

This checker can be extended through the Klocwork knowledge base. See Tuning Java analysis for more information.