title: Unable to instantiate activity ComponentInfo... java.lang.NullPointerException
body: <p>I'm having the error "Unable to instantiate activity ComponentInfo" in my app. I had already declared the Activity in AndroidManifest.xml, but I still get the error. I don't know what it is. Does anyone can help?</p>
  
  <p>thanks</p>
  
  <p>The error:</p>
  
  <pre><code>    FATAL EXCEPTION: main
  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{br.com.controladoratividades/br.com.controladoratividades.activities.NovaAtividadeActivity}: java.lang.NullPointerException
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:123)
  at android.app.ActivityThread.main(ActivityThread.java:4627)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:521)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
  at android.content.ContextWrapper.getResources(ContextWrapper.java:80)
  at android.content.Context.getString(Context.java:182)
  at br.com.controladoratividades.activities.NovaAtividadeActivity.&lt;init&gt;(NovaAtividadeActivity.java:15)
  at java.lang.Class.newInstanceImpl(Native Method)
  at java.lang.Class.newInstance(Class.java:1429)
  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
  ... 11 more
  </code></pre>
  
  <p>My AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="br.com.controladoratividades"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
  
  
      &lt;application
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name" &gt;
          &lt;activity
              android:name=".activities.ControladorAtividadesActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".activities.NovaAtividadeActivity"
              android:label="@string/nova_atividade" &gt;            
          &lt;/activity&gt;
  
             &lt;activity
              android:name=".activities.PlanejadorActivity"
              android:label="@string/novo_plano" &gt;            
          &lt;/activity&gt;         
  
  
      &lt;/application&gt;
  
      &lt;uses-sdk android:minSdkVersion="7" /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>The activity:</p>
  
  <pre><code>package br.com.controladoratividades.activities;
  
  import br.com.controladoratividades.R;
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  
  public class NovaAtividadeActivity extends Activity {
  
      private String[] DIAS = new String[] {getString(R.string.domingo), 
              getString(R.string.segunda),
              getString(R.string.terca),
              getString(R.string.quarta),
              getString(R.string.quinta),
              getString(R.string.sexta),
              getString(R.string.sabado)};
      protected boolean[] DIAS_SELECIONADOS =  new boolean[ DIAS.length ];
  
      static final int DIAS_DIALOG_ID = 0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.nova_atividade);
  
          Button btAlterarDias = (Button)findViewById(R.id.btSalvarPlano);
          btAlterarDias.setOnClickListener(new AlterarDiasClickHandler());
  
          for (int i = 1;  i &lt; DIAS_SELECIONADOS.length; i++) {
              DIAS_SELECIONADOS[i] = true;
          }
      }
  
      public class AlterarDiasClickHandler implements View.OnClickListener{
  
          @Override
          public void onClick(View v) {
              showDialog(DIAS_DIALOG_ID);
  
          }       
      }
  
      @Override
      protected Dialog onCreateDialog( int id ) 
      {
          return 
          new AlertDialog.Builder( this )
              .setTitle( "Planets" )
              .setMultiChoiceItems( 
                      DIAS,
                      DIAS_SELECIONADOS, 
                      new DialogSelectionClickHandler() )
              .setPositiveButton( "OK", new DialogButtonClickHandler() )
              .create();
      }
  
      public class DialogSelectionClickHandler implements DialogInterface.OnMultiChoiceClickListener
      {
          public void onClick( DialogInterface dialog, int clicked, boolean selected )
          {
              Log.i( "ME", DIAS[ clicked ] + " selected: " + selected );
          }
      }
  
      public class DialogButtonClickHandler implements DialogInterface.OnClickListener
      {
          public void onClick( DialogInterface dialog, int clicked )
          {
              switch( clicked )
              {
                  case DialogInterface.BUTTON_POSITIVE:
                      //printSelectedPlanets();
                      break;
              }
          }
      }
  }
  </code></pre>