0

I've not understood any way to report errors on Android. I use Cxxdroid which comes packaged with SDL2. I could use the terminal and compile the program using clang++; that way I'd have debug text output, but the libraries and includes are hidden away. I don't have access to that information.

SDL_ShowSimpleMessageBox is one way, but not the only way? I've had some success but not every use case.

I thought try-catch would work, so I tried this:


try

{

    while (!game.isQuit)

    {

        game.checkInput();

    }

}

catch(std::exception &e)

{

    SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "title", SDL_GetError(), 0);

}

    game.quit();

    return 0;

}

It's incomplete but you get the idea.

I'll tell you the error which crashed my program...

for(int i = 0; vec.size(); ++i)

The compiler didn't flag it. This crashed because I forgot the test case. My question is how can I log debug text output while using my Android phone?

  • 1
    `for(int i = 0; vec.size(); ++i) ...` is a bit strange but legal code, it loops until `vec` is empty. Undefined Behaviour (eg index out of bounds, null pointer dereference etc) does __not__ throw exceptions. – Richard Critten Mar 25 '23 at 17:12
  • In addition to what Richard said SDL can’t throw exceptions either since it is a C library. – SafelyFast Mar 26 '23 at 00:14
  • If you can't have debug output and display at the same time, then write some function to print what you need to the screen using SDL render calls directly. This sure is hacky, but so is development under cxxdroid. By the way, do not name your question "Can I use try{} catch{} in SDL2 on Android, at all?" if you actual question is "How can I log debug text output while using my Android phone using cxxdroid?". – RedStoneMatt Jul 05 '23 at 09:49

0 Answers0