title: Whats wrong with my Android Studio App keep stopping?
body: <p>For some reason my app is keep coming up with <em>"app name"</em> has stopped. I have added the error log below but cannot work out what the problem is. I have tried many times to figure it out but still not getting anywhere. Hopefully you can understand the error log.</p>
  
  <pre><code>04-29 12:20:07.016 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.019 1694-4363/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
  04-29 12:20:07.019 1694-4363/system_process D/OpenGLRenderer: Swap behavior 1
  04-29 12:20:07.019 1694-4363/system_process W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
  04-29 12:20:07.019 1694-4363/system_process D/OpenGLRenderer: Swap behavior 0
  04-29 12:20:07.020 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.070 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.465 1694-1712/system_process W/ActivityManager: Activity pause timeout for ActivityRecord{6dd3b2c u0 thomashaywoodproductions.buildaempiredesign/.GameLogin t154 f}
  04-29 12:20:07.481 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x333 imply creation of host color buffer
  
                                                   [ 04-29 12:20:07.485  1694: 1712 D/         ]
                                                   HostConnection::get() New Host Connection established 0x96c6e480, tid 1712
  04-29 12:20:07.521 1296-1296/? E/EGL_emulation: tid 1296: eglCreateSyncKHR(1669): error 0x3004 (EGL_BAD_ATTRIBUTE)
  04-29 12:20:07.558 1296-1353/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.559 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.560 1694-1712/system_process D/gralloc_ranchu: gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
  04-29 12:20:07.569 1296-1353/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.586 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.594 1296-1353/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.601 1296-2069/? D/gralloc_ranchu: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
  04-29 12:20:07.687 2343-2343/com.google.android.googlequicksearchbox:search I/OptInState: There is a new client and it does not support opt-in. Dropping request.
  04-29 12:20:07.692 2343-2343/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: Micro detection mode: [mDetectionMode: [1]].
  04-29 12:20:07.693 2343-2343/com.google.android.googlequicksearchbox:search I/AudioController: Using mInputStreamFactoryBuilder
  04-29 12:20:07.700 2343-18556/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Starting detection.
  04-29 12:20:07.701 2343-9163/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_starting com.google.android.apps.gsa.staticplugins.z.c@6dbc476
  04-29 12:20:07.702 1305-1775/? W/APM_AudioPolicyManager: getInputForAttr() failed opening input: samplingRate 16000, format 1, channelMask 10
  04-29 12:20:07.702 2343-9163/com.google.android.googlequicksearchbox:search E/AudioRecord: Could not get audio input for session 4025, record source 1999, sample rate 16000, format 0x1, channel mask 0x10, flags 0
  04-29 12:20:07.703 2343-9163/com.google.android.googlequicksearchbox:search E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22.
  04-29 12:20:07.703 2343-9163/com.google.android.googlequicksearchbox:search E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
  04-29 12:20:07.703 2343-9163/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_started com.google.android.apps.gsa.staticplugins.z.c@6dbc476
  04-29 12:20:07.703 2343-9163/com.google.android.googlequicksearchbox:search E/ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
  04-29 12:20:07.704 2343-2343/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: onReady
  04-29 12:20:07.706 2343-18556/com.google.android.googlequicksearchbox:search W/SpeechLevelGenerator: Really low audio levels detected. The audio input may have issues.
  04-29 12:20:07.715 2343-18556/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Detection finished
  04-29 12:20:07.714 2343-9163/com.google.android.googlequicksearchbox:search I/MicrophoneInputStream: mic_close com.google.android.apps.gsa.staticplugins.z.c@6dbc476
  04-29 12:20:07.715 2343-18556/com.google.android.googlequicksearchbox:search W/ErrorReporter: reportError [type: 211, code: 524300]: Error reading from input stream
  04-29 12:20:07.716 2343-2485/com.google.android.googlequicksearchbox:search I/MicroRecognitionRunner: Stopping hotword detection.
  04-29 12:20:07.716 2343-18556/com.google.android.googlequicksearchbox:search W/ErrorProcessor: onFatalError, processing error from engine(4)
                                                                                                 com.google.android.apps.gsa.shared.speech.a.g: Error reading from input stream
                                                                                                     at com.google.android.apps.gsa.staticplugins.recognizer.i.a.a(SourceFile:342)
                                                                                                     at com.google.android.apps.gsa.staticplugins.recognizer.i.a$1.run(SourceFile:1367)
                                                                                                     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
                                                                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                                     at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66)
                                                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
                                                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
                                                                                                     at java.lang.Thread.run(Thread.java:761)
                                                                                                     at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85)
                                                                                                  Caused by: com.google.android.apps.gsa.shared.exception.GsaIOException: Error code: 393238 | Buffer overflow, no available space.
                                                                                                     at com.google.android.apps.gsa.speech.audio.Tee.g(SourceFile:2531)
                                                                                                     at com.google.android.apps.gsa.speech.audio.ap.read(SourceFile:555)
                                                                                                     at java.io.InputStream.read(InputStream.java:101)
                                                                                                     at com.google.android.apps.gsa.speech.audio.al.run(SourceFile:362)
                                                                                                     at com.google.android.apps.gsa.speech.audio.ak$1.run(SourceFile:471)
                                                                                                     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
                                                                                                     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                                     at com.google.android.apps.gsa.shared.util.concurrent.a.ak.run(SourceFile:66)
                                                                                                     at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139)
                                                                                                     at com.google.android.apps.gsa.shared.util.concurrent.a.ax.run(SourceFile:139)
                                                                                                     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
                                                                                                     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
                                                                                                     at java.lang.Thread.run(Thread.java:761) 
                                                                                                     at com.google.android.apps.gsa.shared.util.concurrent.a.ad$1.run(SourceFile:85) 
  04-29 12:20:07.717 2343-18556/com.google.android.googlequicksearchbox:search I/AudioController: internalShutdown
  04-29 12:20:07.718 2343-2343/com.google.android.googlequicksearchbox:search I/MicroDetector: Keeping mic open: false
  04-29 12:20:07.718 2343-2343/com.google.android.googlequicksearchbox:search I/MicroDetectionWorker: #onError(false)
  04-29 12:20:07.718 2343-18555/com.google.android.googlequicksearchbox:search I/DeviceStateChecker: DeviceStateChecker cancelled
  04-29 12:20:08.132 1694-1719/system_process D/gralloc_ranchu: gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
  04-29 12:20:08.134 1694-1719/system_process W/WindowManager: Failed looking up window
                                                               java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W@f29c3c4 does not exist
                                                                   at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9415)
                                                                   at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9406)
                                                                   at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2387)
                                                                   at com.android.server.wm.Session.remove(Session.java:193)
                                                                   at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:3290)
                                                                   at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5917)
                                                                   at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3626)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                   at android.os.Looper.loop(Looper.java:154)
                                                                   at android.os.HandlerThread.run(HandlerThread.java:61)
                                                                   at com.android.server.ServiceThread.run(ServiceThread.java:46)
  04-29 12:20:08.146 2216-2360/com.google.android.apps.nexuslauncher W/OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
  </code></pre>
  
  <p>Here is the file code </p>
  
  <pre><code>public class GameLogin extends AppCompatActivity {
      SharedPreferences sharedPref = GameLogin.this.getPreferences(Context.MODE_PRIVATE);
      SharedPreferences.Editor editor = sharedPref.edit();
      EditText etEmail;
      EditText etPassword;
      Button bLogin;
      TextView registerLink;
  
      @Override
      protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_game_login);
  
  
  
          etEmail = (EditText) findViewById(R.id.etEmail);
          etPassword = (EditText) findViewById(R.id.etPassword);
          bLogin = (Button) findViewById(R.id.bLogin);
          registerLink = (TextView) findViewById(R.id.tvRegisterHere);
  
          registerLink.setOnClickListener(new View.OnClickListener(){
              @Override
              public void onClick(View v){
                  Intent registerIntent = new Intent(GameLogin.this, GameRegister.class);
                  GameLogin.this.startActivity(registerIntent);
              }
          });
  
          bLogin.setOnClickListener(new View.OnClickListener(){
              @Override
              public void onClick(View v){
                  final String email = etEmail.getText().toString();
                  final String password = etPassword.getText().toString();
  
                  Response.Listener&lt;String&gt; responceListener = new Response.Listener&lt;String&gt;(){
  
                      @Override
                      public void onResponse(String response) {
                          try {
                              JSONObject jsonResponce = new JSONObject(response);
                              boolean success = jsonResponce.getBoolean("success");
                              if (success){
                                  editor.putString(getString(R.string.player_data_gamename), jsonResponce.getString("gamename"));
                                  editor.putString(getString(R.string.player_data_startdate), jsonResponce.getString("startdate"));
                                  editor.putInt(getString(R.string.player_data_userid), jsonResponce.getInt("userid"));
                                  editor.commit();
  
                                  Intent intent = new Intent(GameLogin.this, GameUserArea.class);
                                  GameLogin.this.startActivity(intent);
  
                              } else {
                                  AlertDialog.Builder builder = new AlertDialog.Builder(GameLogin.this);
                                  builder.setMessage("Login Failed")
                                          .setNegativeButton("Retry", null)
                                          .create()
                                          .show();
                              }
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
                      }
                  };
  
                  LoginRequest loginRequest = new LoginRequest(email, password, responceListener);
              }
          });
      }
  }
  </code></pre>