0

I write code for MSN application , and this application connection with server ASP.NET this code run perfectly in my computer , but when I run this code in other computer it is giving me runtime error in this line

new SigninPerson(s1,s2);

Error:

could not find class 'com.example.hello.Signinperson' referenced from method
com.example.hello.MainActivity.GoToProfileActivity

Code:

public class MainActivity extends Activity {
    public final String URL="http://10.0.2.2:47102/ProjectTwo/Service.asmx";
    public final String NAMESPACE="http://tempuri.org/";
    public final String METHOD= "signin";
    public final String ACTION = "http://tempuri.org/signin";
    private EditText EditTextEmail;
    private EditText EditTextPass;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void GoToSignupActivity (View V)
    {
        Intent SignupAct = new Intent("com.example.hello.SignupActivity");
        startActivity(Intent.createChooser(SignupAct, "Choose an Application"));
    }
    public void GoToProfileActivity (View V)
    {
        EditTextEmail = (EditText) findViewById(R.id.Edit_Text_Email);
        EditTextPass = (EditText) findViewById(R.id.Edit_Text_Pass);
        if (isEmptyEditText(EditTextEmail) | isEmptyEditText(EditTextPass)) 
        {
            showDialog(0);
        }
        else
        {
            String s1 = EditTextEmail.getText().toString().trim();
            String s2 = EditTextPass.getText().toString().trim();
            SigninPerson SIPerson = new SigninPerson(s1,s2);
            SoapObject Req = new SoapObject(NAMESPACE, METHOD);
            PropertyInfo p = new PropertyInfo();
            p.setName("SIPerson");
            p.setValue(SIPerson);
            p.setType(SIPerson.getClass());
            Req.addProperty(p);
            SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
            env.dotNet = true;

            env.setOutputSoapObject(Req);
            env.addMapping(NAMESPACE, "SigninPerson", new SigninPerson().getClass());
            HttpTransportSE ahttp = new HttpTransportSE(URL);
            SoapObject Res = null;
            try
            {
                ahttp.call(ACTION, env);
                Res = (SoapObject) env.getResponse();
            }
            catch (Exception ex)
            {
                ex.printStackTrace();
            }
            if (Integer.parseInt(Res.getProperty(0).toString())==0)
            {
                showDialog(1);
            }
            else
            {
                SIPerson.Person_Id = Integer.parseInt(Res.getProperty(0).toString());
                SIPerson.F_Name = Res.getPropertyAsString(1).toString();
                SIPerson.L_Name = Res.getPropertyAsString(2).toString();
                SIPerson.E_Mail = Res.getPropertyAsString(3).toString();
                SIPerson.Password = Res.getPropertyAsString(4).toString();
                Intent ProfileAct = new Intent("com.example.hello.ProfileActivity");
                ProfileAct.putExtra("ReciveLogin", SIPerson);
                startActivity(Intent.createChooser(ProfileAct, "Choose an Application"));
            }
        }
    }
    public boolean isEmptyEditText (EditText ET)
    {
        boolean isEmpty = true;
        if (ET.getText().toString().trim().length() > 0)
        {
            isEmpty = false;
        }
        return isEmpty;
    }
    @Override
    protected Dialog onCreateDialog(int id)
    {
        switch (id)
        {
        case 0:
            Dialog EnterBothDialog = new Dialog(this);
            EnterBothDialog.setTitle("Please Enter Both E-Mail / Password");
            return EnterBothDialog;
        case 1:
            Dialog InvalidEmPass = new Dialog(this);
            InvalidEmPass.setTitle("Invalid Email / Password");
            return InvalidEmPass;
        }
        return null;
    }
}

and this is SigninPerson

public class SigninPerson implements KvmSerializable, Serializable {
    public int Person_Id;
    public String F_Name;
    public String L_Name;
    public String E_Mail;
    public String Password;
    public SigninPerson () 
    {
    }
    public SigninPerson (int id, String Fname, String Lname, String Email, String Pass)
    {
        Person_Id = id;
        F_Name = Fname;
        L_Name = Lname;
        E_Mail = Email;
        Password = Pass;
    }

    public SigninPerson (String Email, String Pass)
    {
        Person_Id = 0;
        F_Name = "";
        L_Name = "";
    }
    @Override
    public Object getProperty(int arg0) {
        // TODO Auto-generated method stub
        switch (arg0)
        {
        case 0:
            return Person_Id;
        case 1:
            return F_Name;
        case 2:
            return L_Name;
        case 3:
            return E_Mail;
        case 4:
            return Password;
        }
        return null;
    }

    @Override
    public int getPropertyCount() {
        // TODO Auto-generated method stub
        return 5;
    }

    @Override
    public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
        // TODO Auto-generated method stub
        switch (arg0)
        {
        case 0:
            arg2.type = PropertyInfo.INTEGER_CLASS;
            arg2.name = "Person_Id";
            break;
        case 1:
            arg2.type = PropertyInfo.STRING_CLASS;
            arg2.name = "F_Name";
            break;
        case 2:
            arg2.type = PropertyInfo.STRING_CLASS;
            arg2.name = "L_Name";
            break;
        case 3:
            arg2.type = PropertyInfo.STRING_CLASS;
            arg2.name = "E_Mail";
            break;
        case 4:
            arg2.type = PropertyInfo.STRING_CLASS;
            arg2.name = "Password";
            break;
            default:break;
        }
    }

    @Override
    public void setProperty(int arg0, Object arg1) {
        // TODO Auto-generated method stub
        switch (arg0)
        {
        case 0:
            Person_Id = Integer.parseInt(arg1.toString());
            break;
        case 1:
            F_Name = arg1.toString();
            break;
        case 2:
            L_Name = arg1.toString();
            break;
        case 3:
            E_Mail = arg1.toString();
            break;
        case 4:
            Password = arg1.toString();
            break;
            default:break;
        }
    }

}

but when I delete implements from SigninPerson and Override

public class SigninPerson{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public int Person_Id;
    public String F_Name;
    public String L_Name;
    public String E_Mail;
    public String Password;
    public SigninPerson () 
    {
    }
    public SigninPerson (int id, String Fname, String Lname, String Email, String Pass)
    {
        Person_Id = id;
        F_Name = Fname;
        L_Name = Lname;
        E_Mail = Email;
        Password = Pass;
    }

    public SigninPerson (String Email, String Pass)
    {
        Person_Id = 0;
        F_Name = "";
        L_Name = "";
    }
}

it is make new for SigninPerson and don't give me run time

I am trying to found the problem long time but I can't find any wrong

please , anyone can help me

because I must send my application in the morning

4
  • 2
    What is the specific error message? Commented Jul 18, 2013 at 1:58
  • could not find class 'com.example.hello.Signinperson' referenced from method com.example.hello.MainActivity.GoToProfileActivity Commented Jul 18, 2013 at 2:10
  • 1
    -1 for not quoting the exact message. Commented Jul 18, 2013 at 2:11
  • 1
    Did it occur to you that it can't find com.example.hello.Signinperson because you don't have it in a correct spot in the classpath? (Is there a directory named "com" in your classpath?) Commented Jul 18, 2013 at 2:15

2 Answers 2

2

You should change this line:

SigninPerson SIPerson = null;
new SigninPerson(s1,s2);

to:

SigninPerson SIPerson = new SigninPerson(s1,s2);
Sign up to request clarification or add additional context in comments.

4 Comments

That won't solve the poster's problem (assuming they have described it correctly) although it will fix later runtime errors.
Initially, I wrote SigninPerson SIPerson = new SigninPerson(s1,s2); but when it is give me run time I changed the line to SigninPerson SIPerson = null; new SigninPerson(s1,s2); but it still give me run time error
thank you, I edit this problem, but it still give me run time error
@ferasAboZoheer you should look into HotLicks comment and check your classpath then.
1

It'll give you a NullPointerException as you declared a reference for the SigninPerson, but you never assigned it to a new object of this class as @SOfanatic recommended for you ( +1 for him).

 SigninPerson SIPerson = null;// << here assign SIPerson to new SigninPerson
    //....
     p.setValue(SIPerson);
     p.setType(SIPerson.getClass());

1 Comment

thank you, I edit this problem, but it still give me run time error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.