I have an app that is not in the market place (signed with a debug certificate), but would like to get crash log data, whenever my application crashes. Where can I find a lo
Use acra crash reporter for android app..Acra lib
Base on this POST, use this class as replacement of "TopExceptionHandler"
class TopExceptionHandler implements Thread.UncaughtExceptionHandler {
private Thread.UncaughtExceptionHandler defaultUEH;
private Activity app = null;
private String line;
public TopExceptionHandler(Activity app) {
this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
this.app = app;
}
public void uncaughtException(Thread t, Throwable e) {
StackTraceElement[] arr = e.getStackTrace();
String report = e.toString()+"\n\n";
report += "--------- Stack trace ---------\n\n";
for (int i=0; i<arr.length; i++) {
report += " "+arr[i].toString()+"\n";
}
report += "-------------------------------\n\n";
// If the exception was thrown in a background thread inside
// AsyncTask, then the actual exception can be found with getCause
report += "--------- Cause ---------\n\n";
Throwable cause = e.getCause();
if(cause != null) {
report += cause.toString() + "\n\n";
arr = cause.getStackTrace();
for (int i=0; i<arr.length; i++) {
report += " "+arr[i].toString()+"\n";
}
}
report += "-------------------------------\n\n";
try {
FileOutputStream trace = app.openFileOutput("stack.trace",
Context.MODE_PRIVATE);
trace.write(report.getBytes());
trace.close();
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"kevineyni@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "crash report azar");
String body = "Mail this to kevineyni@gmail.com: " + "\n" + trace + "\n";
i.putExtra(Intent.EXTRA_TEXT , body);
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
// Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
// ReaderScopeActivity.this.startActivity(Intent.createChooser(sendIntent, "Title:"));
//ReaderScopeActivity.this.deleteFile("stack.trace");
} catch(IOException ioe) {
// ...
}
defaultUEH.uncaughtException(t, e);
}
private void startActivity(Intent chooser) {
}
}
.....
in same java class file (Activity) .....
Public class MainActivity.....
.....
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.setDefaultUncaughtExceptionHandler(new TopExceptionHandler(this));
.....
If you're using Eclipse, make sure you use debug and not run. Make sure you are in the debug perspective (top right) You may have to hit 'Resume' (F8) a few times for the log to print. The crash log will be in the Logcat window at the bottom- double click for fullscreen and make sure you scroll to the bottom. You'll see red text for errors, the crash trace will be something like
09-04 21:35:15.228: ERROR/AndroidRuntime(778): Uncaught handler: thread main exiting due to uncaught exception
09-04 21:35:15.397: ERROR/AndroidRuntime(778): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dazlious.android.helloworld/com.dazlious.android.helloworld.main}: java.lang.ArrayIndexOutOfBoundsException
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.os.Handler.dispatchMessage(Handler.java:99)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.os.Looper.loop(Looper.java:123)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.ActivityThread.main(ActivityThread.java:3948)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at java.lang.reflect.Method.invokeNative(Native Method)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at java.lang.reflect.Method.invoke(Method.java:521)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at dalvik.system.NativeStart.main(Native Method)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): Caused by: java.lang.ArrayIndexOutOfBoundsException
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at com.example.android.helloworld.main.onCreate(main.java:13)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
09-04 21:35:15.397: ERROR/AndroidRuntime(778): ... 11 more
The important parts for this one are
09-04 21:35:15.397: ERROR/AndroidRuntime(778): Caused by: java.lang.ArrayIndexOutOfBoundsException
09-04 21:35:15.397: ERROR/AndroidRuntime(778): at com.example.android.helloworld.main.onCreate(main.java:13)
those tell us it was an array out of bounds exception on on line 13 of main.java in the onCrate method.
Try Carsh log app from android.
use the link to download app.
This is from http://www.herongyang.com/Android/Debug-adb-logcat-Command-Debugging.html
You can use adb:
adb logcat AndroidRuntime:E *:S
Here is a solution that can help you dump all the logs onto a text file
adb logcat -d > logs.txt