title: Strange error java.lang.reflect.Method.invokeNative(Native Method) Android Studio please answer
body: <p>I'm developing an app for my school with a timetable and a little calculator</p>
  
  <p>Here's the manifest.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="com.example.markwitt.schul_app"&gt;
  
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:launchMode="singleTop"
      android:minSdkVersion="20"
      android:supportsRtl="true"
      android:targetSdkVersion="25"
      android:theme="@style/AppTheme"&gt;
      &lt;activity android:name=".Stundenplan"&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=".Vertretungsplan" /&gt;
      &lt;activity android:name=".Rechner" /&gt;
      &lt;activity android:name=".Overlay"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here's the Launcher activity activity_stundenplan.xml:</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:background="@color/white"&gt;
  
      &lt;Button
          android:text="Rechner"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/buttonrechner"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_marginLeft="44dp"
          android:layout_marginStart="44dp" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/buttonvertr"
          android:text="Vertretungsplan"
          android:layout_alignParentBottom="true"
          android:layout_alignRight="@+id/Tabelle"
          android:layout_alignEnd="@+id/Tabelle" /&gt;
  
  &lt;TableLayout
      android:id="@+id/Tabelle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      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.markwitt.schul_app.Stundenplan"
      android:background="@color/white"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"&gt;
  
  
          &lt;TableRow
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;TextView
                  android:text="@string/r10"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r20"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r30"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r40"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r50"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r60"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
          &lt;/TableRow&gt;
          &lt;TableRow
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;TextView
                  android:text="@string/r11"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
              &lt;TextView android:text="@string/r21" android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r31"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r41"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r51"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r61"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
          &lt;/TableRow&gt;
          &lt;TableRow
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;TextView
                  android:text="@string/r12"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:textStyle="normal|bold"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r22"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r32"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r42"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r52"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content" /&gt;
  
              &lt;TextView
                  android:text="@string/r62"
                  android:padding="10dp"
                  android:background="@drawable/cell_shape"
              //more TableRows
              &lt;/TableLayout&gt;
              &lt;/Relativelayout&gt;
  </code></pre>
  
  <p>I've made an Intent in Stundenplan.java:</p>
  
  <pre><code>rechner.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              startActivity(new Intent(Stundenplan.this, Rechner.class));
          }
      });
  </code></pre>
  
  <p>The Problem is that everytime I debug-launch the app on my Xperia Z3 and press the button to open the "Rechner"-Activity, the app closes and it shows me the following error:(sry for the bad format)</p>
  
  <pre><code>I/OpenGLRenderer: Initialized EGL, version 1.4
  I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@f97be6e time:6061206
  I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@f97be6e time:6065998
  I/Timeline: Timeline: Activity_launch_request id:com.example.markwitt.schul_app time:6074313
  D/AndroidRuntime: Shutting down VM
  
  
                    --------- beginning of crash
  E/AndroidRuntime: FATAL EXCEPTION: main
                    Process: com.example.markwitt.schul_app, PID: 22562
                    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.markwitt.schul_app/com.example.markwitt.schul_app.Rechner}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2375)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
                        at android.app.ActivityThread.access$900(ActivityThread.java:154)
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:224)
                        at android.app.ActivityThread.main(ActivityThread.java:5526)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
                        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:53)
                        at android.support.v7.app.AppCompatDelegateImplV23.&lt;init&gt;(AppCompatDelegateImplV23.java:29)
                        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:203)
                        at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:185)
                        at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:525)
                        at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:193)
                        at com.example.markwitt.schul_app.Rechner.&lt;init&gt;(Rechner.java:16)
                        at java.lang.Class.newInstance(Native Method)
                        at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2365)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) 
                        at android.app.ActivityThread.access$900(ActivityThread.java:154) 
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391) 
                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                        at android.os.Looper.loop(Looper.java:224) 
                        at android.app.ActivityThread.main(ActivityThread.java:5526) 
                        at java.lang.reflect.Method.invoke(Native Method) 
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  I/Process: Sending signal. PID: 22562 SIG: 9
  Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
  </code></pre>
  
  <p>My Rechner.java and my activity_rechner look like this:</p>
  
  <pre><code>package com.example.markwitt.schul_app;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.RadioButton;
  import android.widget.RadioGroup;
  
  public class Rechner extends AppCompatActivity {
  private RadioGroup radioGroup;
  private RadioButton checked;
  private Button los;
  public String mode;
  EditText number1 = (EditText) findViewById(R.id.nummer1);
  EditText number2 = (EditText) findViewById(R.id.nummer2);
  EditText ergebnis = (EditText) findViewById(R.id.ergebnis);
  public int text1;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_rechner);
  
      addListenerOnButton();
  }
  
  public void addListenerOnButton() {
      radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
      los = (Button) findViewById(R.id.button5);
  
      los.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              int selectedId = radioGroup.getCheckedRadioButtonId();
  
              checked = (RadioButton) findViewById(selectedId);
  
              switch (checked.getId()){
                  case R.id.plus: mode = "+";
                  case R.id.minus: mode = "-";
                  case R.id.mal: mode = "*";
                  case R.id.geteilt: mode = ":";
                  case R.id.fakultaet: mode = "fak";
  
              }
              text1 = Integer.parseInt(number1.getText().toString());
              int text2 = Integer.parseInt(number2.getText().toString());
              switch (mode){
                  case "+": ergebnis.setText(text1 + text2);
                  case "-": ergebnis.setText(text1 - text2);
                  case "*": ergebnis.setText(text1 * text2);
                  case ":": ergebnis.setText(text1 / text2);
                  case "fak": ergebnis.setText(Long.toString(fakultaet(text1)));
              }
  
          }
  
      });
  
  
  
  
  }
  static long fakultaet(int n) {
      int ergebnis = 1;
      for (int i = 1; i &lt;= n; i++) {
          ergebnis = ergebnis * i;
      }
      return ergebnis;
  }
  </code></pre>
  
  <p>}
  ...</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:id="@+id/activity_durchschnitt"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.markwitt.schul_app.Rechner"&gt;
  
  &lt;EditText
      android:id="@+id/nummer1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="12dp"
      android:layout_weight="1"
      android:ems="10"
      android:hint="Nummer 1"
      android:inputType="number"
      android:maxLines="1"
      android:textAlignment="center" /&gt;
  
  &lt;Button
      android:id="@+id/button5"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_above="@+id/ergebnis"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="22dp"
      android:text="=" /&gt;
  
  &lt;RadioGroup
      android:id="@+id/radioGroup"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignParentRight="true"
      android:layout_below="@+id/nummer1"
      android:layout_marginEnd="42dp"
      android:layout_marginRight="42dp"
      android:layout_marginTop="69dp"
      android:orientation="horizontal"&gt;
  
      &lt;RadioButton
          android:id="@+id/mal"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/geteilt"
          android:layout_alignBottom="@+id/geteilt"
          android:layout_toLeftOf="@+id/geteilt"
          android:layout_toStartOf="@+id/geteilt"
          android:layout_weight="1"
          android:text="* "
          android:textAllCaps="true"
          android:textStyle="bold" /&gt;
  
      &lt;RadioButton
          android:id="@+id/fakultaet"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/mal"
          android:layout_alignBottom="@+id/mal"
          android:layout_toLeftOf="@+id/mal"
          android:layout_toStartOf="@+id/mal"
          android:layout_weight="1"
          android:text="Fakultät "
          android:textAllCaps="true"
          android:textStyle="bold" /&gt;
  
      &lt;RadioButton
          android:id="@+id/plus"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/minus"
          android:layout_alignBottom="@+id/minus"
          android:layout_toEndOf="@+id/nummer1"
          android:layout_toRightOf="@+id/nummer1"
          android:layout_weight="1"
          android:text="+ "
          android:textAllCaps="true"
          android:textStyle="bold" /&gt;
  
      &lt;RadioButton
          android:id="@+id/geteilt"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/radioGroup"
          android:layout_toEndOf="@+id/radioGroup"
          android:layout_toRightOf="@+id/radioGroup"
          android:layout_weight="1"
          android:text=": "
          android:textAllCaps="true"
          android:textStyle="bold" /&gt;
  
      &lt;RadioButton
          android:id="@+id/minus"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/geteilt"
          android:layout_alignBottom="@+id/geteilt"
          android:layout_toLeftOf="@+id/plus"
          android:layout_toStartOf="@+id/plus"
          android:layout_weight="1"
          android:text="- "
          android:textAllCaps="true"
          android:textStyle="bold" /&gt;
  
  &lt;/RadioGroup&gt;
  
  &lt;EditText
      android:id="@+id/ergebnis"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/nummer2"
      android:layout_alignParentBottom="true"
      android:layout_alignStart="@+id/nummer2"
      android:layout_marginBottom="61dp"
      android:ems="10"
      android:hint="Ergebnis"
      android:inputType="number"
      android:textAlignment="center" /&gt;
  
  &lt;EditText
      android:id="@+id/nummer2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/nummer1"
      android:layout_alignStart="@+id/nummer1"
      android:layout_centerVertical="true"
      android:ems="10"
      android:hint="Nummer 2"
      android:inputType="number"
      android:textAlignment="center" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Can you please give me an answer what to do? It does the same on my phone and on my emulator
  If you have questions, contact me please! </p>
  
  <p>PS: I have to finish it till the 12th December</p>