4

I am working on a project which will not be published in google play. My client is running it on beta. They says it crashes sometimes, but I was never able to reproduce the scenarios.

So I just want to generate a LOG file when the app crashes. Is it possible to get such events?

i.e When the app forces to close I need to generate a log file with the last few actions ( logcat items) .

5 Answers5

3

You can tell your client to install aLogcat ,using this he can get the log of your app

Here is the link aLogcat

Abx
  • 2,852
  • 4
  • 30
  • 50
3

Following is the code which allows you to generate a log file from "logs".

try {
  Process process = Runtime.getRuntime().exec("logcat -d");
  BufferedReader bufferedReader = new BufferedReader(
  new InputStreamReader(process.getInputStream()));

  StringBuilder log=new StringBuilder();
  String line;
  while ((line = bufferedReader.readLine()) != null) {
     log.append(line);
  }
} 
catch (IOException e) {
    //handle exception
}

Permission you need to take is

<uses-permission android:name="android.permission.READ_LOGS"/>
Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
0

You can register UncaughtExceptionHandler for your application and log unexpected crashes to file.

Check this out, Global uncaught exception handler -> email log to me?

Community
  • 1
  • 1
Anirudh
  • 389
  • 1
  • 7
0

use crittercism library crittercism crash reporting

this sends crash logs on your registered account and you can register email id's on which you want crash logs

anddevmanu
  • 1,459
  • 14
  • 19
0

The best and easiest way to log error to a the phone's storage device I found is this which refers to a tutorial here

Community
  • 1
  • 1
viper
  • 1,836
  • 4
  • 25
  • 41