找不到源 - 应用程序意外停止工作

时间:2012-01-12 11:31:36

标签: android

当我点击提交按钮时...当我调试时显示为“找不到源”...并且在设备显示为应用程序已意外停止工作...

Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new View.OnClickListener() {                           
            public void onClick(View view) {
                //finish();
                //Intent DiscIntent = new Intent (view.getContext(), Disclaimer.class);
                //startActivityForResult(DiscIntent, 0);
                if(ValidateInformation())
                {
                    EditText etUserName = (EditText)findViewById(R.id.txtUserName);

                if(UserNameAvailability(view, etUserName.getText().toString().trim()))

我的Logcat详情如下......

   01-12 16:52:39.664: E/AndroidRuntime(338): Uncaught handler: thread main exiting due to uncaught exception
01-12 16:52:39.674: E/AndroidRuntime(338): java.lang.NullPointerException: println needs a message
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.util.Log.println(Native Method)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.util.Log.w(Log.java:157)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.anb.eCalculator.RegisterActivity.UserNameAvailability(RegisterActivity.java:236)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.anb.eCalculator.RegisterActivity$3.onClick(RegisterActivity.java:73)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.View.performClick(View.java:2364)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.View.onTouchEvent(View.java:4179)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.View.dispatchTouchEvent(View.java:3709)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.os.Looper.loop(Looper.java:123)
01-12 16:52:39.674: E/AndroidRuntime(338):  at android.app.ActivityThread.main(ActivityThread.java:4363)
01-12 16:52:39.674: E/AndroidRuntime(338):  at java.lang.reflect.Method.invokeNative(Native Method)
01-12 16:52:39.674: E/AndroidRuntime(338):  at java.lang.reflect.Method.invoke(Method.java:521)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-12 16:52:39.674: E/AndroidRuntime(338):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-12 16:52:39.674: E/AndroidRuntime(338):  at dalvik.system.NativeStart.main(Native Method)

我的UserNameAvailability功能低于

protected boolean UserNameAvailability(View view, final String sUserName)

{
    boolean result = false;

SoapObject request = new SoapObject(getResources().getString(R.string.targetnamespace), getResources().getString(R.string.usernameavailabilitymethod));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;

PropertyInfo piUserName = new PropertyInfo();
piUserName.name = "UserName";

request.addProperty(piUserName, sUserName);

HttpTransportSE httpTransport = new HttpTransportSE(getResources().getString(R.string.webserviceurl));                 
    try {
        httpTransport.debug =true;
        httpTransport.call(getResources().getString(R.string.usernameavailabilitysoapaction), envelope);                    
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); 
        if (!response.toString().equals("false")) {
            result = true;

        }
        else
        {
            alertBox("User Name already exists.Please enter different username.");
        }

      }catch (Exception exception) {
        Log.w("UserRegistration - RegisterActivity", exception.getMessage());
      }


      return result;

}

我的完整按钮点击事件在

下面
 Button btnSubmit = (Button) findViewById(R.id.btnSubmit);
        btnSubmit.setOnClickListener(new View.OnClickListener() {                           
            public void onClick(View view) {
                //finish();
                //Intent DiscIntent = new Intent (view.getContext(), Disclaimer.class);
                //startActivityForResult(DiscIntent, 0);
                if(ValidateInformation())
                {
                    EditText etUserName = (EditText)findViewById(R.id.txtUserName);

                if(UserNameAvailability(view, etUserName.getText().toString().trim()))
                {
                 EditText etFirstName = (EditText)findViewById(R.id.txtFirstName);
                 EditText etLastName = (EditText)findViewById(R.id.txtLastName);        
                 EditText etEmail = (EditText)findViewById(R.id.txtEmail);      
                 EditText etQuery= (EditText)findViewById(R.id.txtQuery);
                 EditText etTelephone = (EditText)findViewById(R.id.txtTelePhone);
                 EditText etOrganization = (EditText)findViewById(R.id.txtOrganization);
                 EditText etRegion = (EditText)findViewById(R.id.txtRegionCountry);
                 EditText etPassword = (EditText)findViewById(R.id.txtPassword);
                 EditText etConfirmPassword = (EditText)findViewById(R.id.txtConfirmPassword);//Added By Prakash
                 //EditText etUserName1 = (EditText)findViewById(R.id.txtUserName); 



                Bundle bunUserInfo = new Bundle();
                bunUserInfo.putString("UserName", etUserName.getText().toString());
                bunUserInfo.putString("FirstName", etFirstName.getText().toString());
                bunUserInfo.putString("LastName", etLastName.getText().toString());
                bunUserInfo.putString("Email", etEmail.getText().toString());
                bunUserInfo.putString("Query", etQuery.getText().toString());
                bunUserInfo.putString("Telephone", etTelephone.getText().toString());
                bunUserInfo.putString("Organization", etOrganization.getText().toString());
                bunUserInfo.putString("Region", etRegion.getText().toString());
                bunUserInfo.putString("Password", etPassword.getText().toString());
                bunUserInfo.putString("ConfirmPassword", etConfirmPassword.getText().toString());
                //bunUserInfo.putString("UserName", etUserName1.getText().toString());




                Intent goToNextActivity = new Intent(getApplicationContext(), Disclaimer.class);
                goToNextActivity.putExtras(bunUserInfo);
                startActivity(goToNextActivity);
                }
                else
                {
                    alertBox("User Name already exists. Please enter different User Name.");
                }
            }

            }
        });

2 个答案:

答案 0 :(得分:2)

我的猜测是UserNameAvailability在某处调用带有null参数的Log.w。

在UserNameAvailability中查找对Log.w的调用,其中标记或消息为空。

答案 1 :(得分:1)

更改此行

Log.w("UserRegistration - RegisterActivity", exception.getMessage());

Log.w("UserRegistration - RegisterActivity", "Error message is "+exception.getMessage(), exception);

这样,即使exception.getMessage()函数返回null,您也总会有一条消息(以及日志中的堆栈跟踪);