Search code examples
androidnullpointerexceptionbindex

Nullpointer exception on activity launch


I have an error in the perfectly running app before. The snapshot shown here came after i cleaned the project. The android code is perfectly right to my best knowledge.

   package com.tmresponseportal;

 import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
 import android.view.View;
 import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Client1 extends Activity {
TextView text1,tvforpass;
EditText tbid,tbpwd;
Button bsubmit,bclose;
Emailval el = new Emailval();


public void Intentstr() {
    // TODO Auto-generated method stub
    Intent i1 = new Intent();
    i1.setClass(Client1.this,Clwelcome2.class);
    startActivity(i1);

}

public void Intent_start2() {
    // TODO Auto-generated method stub
    Intent i2 = new Intent();
    i2.setClass(Client1.this,Forpass.class);
    startActivity(i2);
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_client1);


    text1 = (TextView)findViewById(R.id.text1);
    text1.setSelected(true);
    tbid = (EditText)findViewById(R.id.tbid);
    tbpwd = (EditText)findViewById(R.id.tbpwd);
    bsubmit = (Button)findViewById(R.id.bsubmit);
    bclose = (Button)findViewById(R.id.bclose);
    tvforpass = (TextView)findViewById(R.id.tvforpass);


    tvforpass.setOnClickListener(new OnClickListener() {





    bclose.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

             finish();
                System.exit(0);
        }
    });
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_client1, menu);
    return true;
}

}

The app force closes when I try to run or debug it. It wont even launch!! The logcat shows nullpointer exception.

I think the error is something to do with bin>dexedlib or the build path.

here is logcat img

Does anyone have any idea about it. any ideas are greatly appreciated.

Thanks in advance.!

here is the image.


Solution

  • Your project have some library errors,

    Go to properties then fix your java build path, and check if you are using any library project, it should be at same location as your main project