when web service uses for my .apk file in release mode can be unexpectedly stopped

lmrrajeshlmrrajesh USMember
edited June 2015 in Xamarin.Android

when web service uses for my android .apk file in release mode can be unexpectedly stopped application. but it's working fine when it is in debug mode. please solve my error as soon as possible.

Best Answers

  • CasperSkouboCasperSkoubo US
    Accepted Answer

    just turn on debug mode again if its working.

    .....

    Can you paste your code here? I suspect you are not using threads and simply just blocking the UI?

Answers

  • CasperSkouboCasperSkoubo USUniversity, Developer Group Leader
    Accepted Answer

    just turn on debug mode again if its working.

    .....

    Can you paste your code here? I suspect you are not using threads and simply just blocking the UI?

  • lmrrajeshlmrrajesh USMember
    edited June 2015

    protected override void OnCreate(Bundle bundle)
    {
    base.OnCreate(bundle);
    SetContentView(Resource.Layout.LoginPage);
    var btn = FindViewById(Resource.Id.loginBtn);
    EditText userId = FindViewById(Resource.Id.txtUserName);
    string uId;
    EditText pswd = FindViewById(Resource.Id.txtPassword);
    string pWd;
    btn.Click += delegate
    {
    meWebReference.CheckCredentials objons = new meWebReference. CheckCredentials (); //This is web reference
    uId = userId.Text.ToString();
    pWd = pswd.Text.ToString();

                var objArrya=objons.funUserLogin(uId, pWd);   //webmethod in webservice
                string status = objArrya.LoginStatus;
                string mob = objArrya.MobileNumber;
    
                if (status.Equals("1"))
                {
                    var hmActivity = new Intent(this, typeof(HomeActivity));
                    hmActivity.PutExtra("Name", uId);
                    hmActivity.PutExtra("LastLogin", balance.ToString());
                    StartActivity(hmActivity);
                }
    
  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    Put everything from your Click event in a try-catch-Block and expose any exception with a Toast. This way you will be informed about the exception that happens in Release-mode. Do you use any linker settings?

  • lmrrajeshlmrrajesh USMember

    I didn't use any linker settings...

  • lmrrajeshlmrrajesh USMember

    in linking properties i have just given Linking: Sdk Assemblies Only

  • lmrrajeshlmrrajesh USMember

    mr.Sebastian Seidel i put try catch under btnClick but i didn't get any exception the way i was usingj try catch in two ways:
    try
    {
    meWebReference.CheckCredentials objons = new meWebReference. CheckCredentials ();
    uId = userId.Text.ToString();
    pWd = pswd.Text.ToString();

                var objArrya=objons.funUserLogin(uId, pWd);
                decimal balance = objArrya.Balance;
                string status = objArrya.LoginStatus;
                string mob = objArrya.MobileNumber;
    
                if (status.Equals("1"))
                {
                    var hmActivity = new Intent(this, typeof(HomeActivity));
                    hmActivity.PutExtra("Name", uId);
                    hmActivity.PutExtra("LastLogin", balance.ToString());
                    StartActivity(hmActivity);
                }
    

    }
    catch (Exception e)
    {
    Toast.MakeText(this,e.Message,ToastLength.Long);
    }
    Or
    catch (Exception e)
    {
    throw e;
    }

  • CasperSkouboCasperSkoubo USUniversity, Developer Group Leader

    Is your CheckCredentials () long running?

Sign In or Register to comment.