New Android Series - Tutorial # 22 Homework app crashing on launch

0 Sohaib Furqan · October 11, 2016
Hi all. I'm on Tutorial#22 of the android series for beginners by Bucky, and I was trying to code for the challenge he gave. My issue is that when I run the app on the emulator, it crashes and a messagebox with a "Force Close" button appears on the phone. 
The following is my code. I'd appreciate if any of you can tell me what's causing the app to crash without running. Regards. 

package com.bubblesoftweb.gestureshomeworlk; 

import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 
import android.view.MotionEvent; 
import android.view.GestureDetector; 

public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener{ 

Button buckysButton = (Button)findViewById(; 
TextView buckysMsg = (TextView)findViewById(; 
GestureDetectorCompat gestureDetector; 

protected void onCreate(Bundle savedInstanceState) { 

this.gestureDetector = new GestureDetectorCompat(this,this); 

new Button.OnClickListener() 

public void onClick(View v) 

buckysMsg.setText("I just got clicked!"); 


public boolean onDown(MotionEvent e) { 
return false; 

public void onShowPress(MotionEvent e) { 

public boolean onSingleTapUp(MotionEvent e) { 
return false; 

public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { 
buckysMsg.setText("Text changed due to onScroll Gesture "); 
return true; 

public void onLongPress(MotionEvent e) { 

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { 
buckysMsg.setText("Text changed due to onFling Gesture "); 
return true; 

public boolean onTouchEvent(MotionEvent event) { 
return super.onTouchEvent(event); 

Post a Reply


Oldest  Newest  Rating
0 Gary Whitney · October 12, 2016
The most important information you can provide me is the Error message in the run window of Android Studio.
It will point you to the line of code  that causes it to crash.
Short of that I would have to start a new project and paste your code while guessing at the manifest and layout file.
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator