log file for errors?

1k views Asked by At

I am developing an Android-App with "Aide".Aide is an app for developing android apps with android devices. When i start the app, i have created, i get an error like "the app has aborted unfortunately". how can i resolve what happened wrong ? is there a log-file where i can see the stack trace ? is ist possible that everytime an error happens a dialog apperas with the stack trace instead of the message "the app has aborted" ? thanks for everybody who can help me.

Greets

Arne

4

There are 4 answers

1
apesa On

I have never used Aide, but the concept will be the same. You need to be able to debug your app on your phone via your IDE. As an example in Eclipse I would connect my phone via usb and in Eclipse it then shows up as an Android Device in AVD. I then run my App in Debug mode on my phone and all your error output will be in Logcat. Otherwise you will have to code debug logic into your app so that it writes it's own logging onto your fs on you phone.

1
Orabîg On

If you have the Android SDK installed (I guess it's the case), then you can use the adb utility to access the log :

adb logcat

This will show you stacktrace in case of error, and many very other useful informations.

0
JRaymond On

If you want to observe the stack trace, all you need is a LogCat reader, like CatLog, for instance. Note that if your device is Jelly Bean of higher, you'll need root permissions to read the logs.

EDIT: Further research indicates that there is a LogCat reader built into AIDE. The root permission issue still applies.

0
BenjaminWegener On

You got 3 options:

  1. Upgrade into a stable Pro version to use the working LogCat on AIDE

  2. Use USB debugging as mentioned by apesa

  3. Use following function to log to local file:

    public void appendLog(String text) // https://stackoverflow.com/a/6209739/8800831 {
    File logFile = new File("sdcard/log.file"); if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { //BufferedWriter for performance, true to set append to file flag BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); buf.append(text); buf.newLine(); buf. flush(); buf.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }

Use it like this:

try{
       // your code goes here
}catch (Exception e){
       appendLog(e);
}

You need to add permission for writing_external_storage in Manifest.