Phill
Phill

Reputation: 427

Find why Xamarin app Crashes randomly

I am making a app with Xamarin.Forms, the app in the iOS doesn't crash but in Android, Application is crashing randomly, even if I only switch the tabs. What is the best way to find what is making the app to stop working?

Thanks

Upvotes: 1

Views: 1169

Answers (2)

DavidS
DavidS

Reputation: 2934

You can also look into a crash reporting service like Hockey App (https://hockeyapp.net/ -- the free level is enough for getting crash reports). You'll get crashes reported there, including crashes in code that you can't catch.

Crash reports aren't quite as handy has being able to break in the debugger, but it's often enough to point you in the right direction.

Instructions on integrating Hockey App to a Xamarin.Forms app: https://support.hockeyapp.net/kb/client-integration-cross-platform/how-to-integrate-hockeyapp-with-xamarin

Upvotes: 1

Moudiz
Moudiz

Reputation: 7377

What is the best way to find what is making the app to stop working?

well to add exception handling

try {
    // ... 
} catch(Exception e) { 
    // ...
}

or like the below example

public static void main(String[] args) throws FileNotFoundException, IOException {
    try{
        ExceptionHandler(1);
        ExceptionHandler(2);
    }catch(FileNotFoundException e){
        e.printStackTrace();
    }catch(IOException e){
        e.printStackTrace();
    }finally{
        System.out.println(" error to be checked");         
    }
    testException(0);
}


public static void ExceptionHandler(int i) throws FileNotFoundException, IOException{
    if(i =1 ){
        FileNotFoundException myException = new FileNotFoundException("error for code 1 "+i);
        throw myException;
    }else if(i =2){
        throw new IOException("error on 2 ");
    }

}

Upvotes: 1

Related Questions