# How can I Debug my app in real time?

**URL:** <https://discourse.processing.org/t/how-can-i-debug-my-app-in-real-time/15250>\
**Category:** Processing for Android\
**Created:** [November 5, 2019, 11:51am UTC](https://discourse.processing.org/t/how-can-i-debug-my-app-in-real-time/15250 "2019-11-05T11:51:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Post date:** [November 5, 2019, 11:51am UTC](https://discourse.processing.org/t/how-can-i-debug-my-app-in-real-time/15250/1 "2019-11-05T11:51:43Z")

</div>

Hi, people 👋 ;

My app runs well when I try in simulation, but when I’m using it in real time (without the computer), sometimes it crashes and I can’t figure out why…

I’d like to create a .txt or something in the try/catch to see where the error can be appearing (and later check that .txt to find the error).

Someone knows how to do it? or how can I see the error?

_Aquaris M10 4G  
Android version: 6.0_

Thanks in advice 🤗

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 6, 2019, 8:17am UTC](https://discourse.processing.org/t/how-can-i-debug-my-app-in-real-time/15250/2 "2019-11-06T08:17:52Z")

</div>

I’ve a problem with that as well, because often even try/catch doen’t show the error in the console while crashing. I’ve tried to save the error/parameters as text, but it also didn’t work because the app crashed before catching. Saving can at least show until where the code _ **did** _ work properly, but it takes a considerable time and slows down the whole flow.  
So I don’t have an answer but I solely respond because I don’t want The topic to die

---

<div class="post-metadata">

**Author:** ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Post date:** [November 6, 2019, 8:48am UTC](https://discourse.processing.org/t/how-can-i-debug-my-app-in-real-time/15250/3 "2019-11-06T08:48:08Z")

</div>

Thanks @noel, I couldn’t even generate the .txt 😅😅 , or maybe I generate it but don’t find…

Can you tell me or show me how to do it?

I tried things like this:

```auto
try {
        FileWriter file = new FileWriter(getFileStreamPath("notas.txt"), true);
        file.write( "TRYING" );
        file.flush();
        file.close();
    } catch (IOException e) {}

```

or this:

```auto
        try {
            String rute = "/storage/emulated/0/DCIM/filename.txt";
            String content = "Example content";
            File file = new File(rute);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fw = new FileWriter(file);
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(content);
            bw.close();
        } catch (Exception e) {
            e.printStackTrace();
       }

```

In the first one I don’t know where is created, I managed to print the path but even with the path of the file I couldn’t access or find it 😅

In the second one, I didn’t have permissions or something similar 😓 (checked if is easily solvable and thought there have to be an easier way)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 6, 2019, 11:17am UTC](https://discourse.processing.org/t/how-can-i-debug-my-app-in-real-time/15250/4 "2019-11-06T11:17:01Z")

</div>

> [@Waboqueox](#):
>
> Can you tell me or show me how to do it?

I use it this way. This time the file will be written, but sometimes it doesn’t make it to the catch block.  
Later on I will try to get your method working.

```auto
// !! Don't forget to give read/write permission !!

import android.os.Environment;
String path = new String(Environment.getExternalStorageDirectory().getAbsolutePath());
String[] my_parameters = new String[2]; 

// Do not write the parameters in try block
my_parameters[0] = "parameter a";
my_parameters[1] = "parameter b";

try {
  int z = 5/0;
} 
catch (Exception e) { 
  saveStrings(path+"/myErrorsLog.txt", my_parameters);
  e.printStackTrace();
}

```
