Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6759151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:54:00+00:00 2026-05-26T13:54:00+00:00

package com.ebonybutler.cexample3; import android.app.Activity; import android.content.Intent; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener;

  • 0
package com.ebonybutler.cexample3;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo; 
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Main extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    Button b = (Button) findViewById(R.id.button1);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent(Main.this, Second.class));

        }
    });
}

}

Every time I try to run it, the error

‘Sorry! the application example3 (processcom.ebonybutler.cexample3)
has stopped unexpectedly. Please try again.’

I can’t figure out what keeps crashing it at launch because all of the java files seem fine or at least aren’t any bugs. Please help! I’ve added the information from my logcat below but I’m having trying interpreting what its saying to me.

11-02 09:29:10.261: E/AndroidRuntime(276): FATAL EXCEPTION: main
11-02 09:29:10.261: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebonybutler.cexample3/com.ebonybutler.cexample3.Main}: java.lang.NullPointerException
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.os.Looper.loop(Looper.java:123)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-02 09:29:10.261: E/AndroidRuntime(276):  at java.lang.reflect.Method.invokeNative(Native Method)
11-02 09:29:10.261: E/AndroidRuntime(276):  at java.lang.reflect.Method.invoke(Method.java:521)
11-02 09:29:10.261: E/AndroidRuntime(276):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-02 09:29:10.261: E/AndroidRuntime(276):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-02 09:29:10.261: E/AndroidRuntime(276):  at dalvik.system.NativeStart.main(Native Method)
11-02 09:29:10.261: E/AndroidRuntime(276): Caused by: java.lang.NullPointerException
11-02 09:29:10.261: E/AndroidRuntime(276):  at com.ebonybutler.cexample3.Main.onCreate(Main.java:21)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-02 09:29:10.261: E/AndroidRuntime(276):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-02 09:29:10.261: E/AndroidRuntime(276):  ... 11 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:54:01+00:00Added an answer on May 26, 2026 at 1:54 pm

    By my count this is occurring when you set the listener for your button. Are you sure that this button still has the ID button1 in your layout’s xml file? This error would occur if that ID now longer existed in your layout

    Button b = (Button) findViewById(R.id.button1);
    b.setOnClickListener(new OnClickListener() { ... // <-- probably occurring here
    

    Edit

    so in code terms, this is what I am saying. I am saying that maybe you used to have a Button in your main.xml file with the id “button1”. (see below)

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
        >
        <LinearLayout 
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
            <Button android:id="@+id/button1 android:layout_height="wrap_content" android:layout_width="wrap_content" ...></Button>
    

    but perhaps now, you may have changed the id in the layout xml and not changed your code (see ‘newid’ below)

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
        >
        <LinearLayout 
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    >
            <Button android:id="@+id/newid" android:layout_height="wrap_content" android:layout_width="wrap_content" ...></Button>
    

    In this case, findViewById would return null, since no such id would exist in your main.xml file anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.duncan.hello.world; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;
package com.example.Calc; import android.R.string; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter;
package com.android.SMStest; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.Button;
package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.view.View; import android.view.View.OnClickListener; //Create an
package com.ave; import com.ave.R; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageButton;
package com.example.android.home; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class HomeActivity extends
package com.aviyehuda.test.multithreading; import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.Button; import android.widget.TextView;
I have created following activity package com.ali.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import
package com.parseador.prueba; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class main extends
package com.commonsware.android.layouts; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.util.Date; public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.