title: Unable to instantiate activity ComponentInfo Android Studio Error
body: <p>I am newbie ... I ve been trying to create a simple program but it keeps failing so I need some help with this error... what is wrong ?</p>
  
  <p>the error i get is : </p>
  
  <pre><code>08-20 20:08:59.422 6192-6192/com.example.raduc.anew E/AndroidRuntime: FATAL EXCEPTION: main
  
      Process: com.example.raduc.anew, PID: 6192
      java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.raduc.anew/com.example.raduc.anew.MainActivity}: java.lang.NullPointerException
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
          at android.app.ActivityThread.access$900(ActivityThread.java:151)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
          at android.os.Handler.dispatchMessage(Handler.java:110)
          at android.os.Looper.loop(Looper.java:193)
          at android.app.ActivityThread.main(ActivityThread.java:5345)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
          at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
          at android.support.v7.app.AppCompatDelegateImplBase.&lt;init&gt;(AppCompatDelegateImplBase.java:116)
          at android.support.v7.app.AppCompatDelegateImplV9.&lt;init&gt;(AppCompatDelegateImplV9.java:147)
          at android.support.v7.app.AppCompatDelegateImplV11.&lt;init&gt;(AppCompatDelegateImplV11.java:27)
          at android.support.v7.app.AppCompatDelegateImplV14.&lt;init&gt;(AppCompatDelegateImplV14.java:50)
          at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:201)
          at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:181)
          at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:521)
          at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:190)
          at com.example.raduc.anew.MainActivity.&lt;init&gt;(MainActivity.java:17)
          at java.lang.Class.newInstanceImpl(Native Method)
          at java.lang.Class.newInstance(Class.java:1215)
          at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441) 
          at android.app.ActivityThread.access$900(ActivityThread.java:151) 
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
          at android.os.Handler.dispatchMessage(Handler.java:110) 
          at android.os.Looper.loop(Looper.java:193) 
          at android.app.ActivityThread.main(ActivityThread.java:5345) 
          at java.lang.reflect.Method.invokeNative(Native Method) 
          at java.lang.reflect.Method.invoke(Method.java:515) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) 
          at dalvik.system.NativeStart.main(Native Method) 
      java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.raduc.anew/
  </code></pre>
  
  <p>the activity:</p>
  
  <pre><code>package com.example.raduc.anew;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.EditText;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
  
  
      EditText nr1 = (EditText) findViewById(R.id.nr);
  }
  </code></pre>
  
  <p>and my layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.raduc.anew.MainActivity"&gt;
  
  
  
      &lt;EditText
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/nr" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and manifest</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.raduc.anew"&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity android:name=".MainActivity"&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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>It's just a simple try to read someth from a EditText object but I dont't know why I get this error only when I set up a variable...</p>
  
  <p>I</p>