diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java index 7f7117e48..8364e22c3 100644 --- a/project/java/MainActivity.java +++ b/project/java/MainActivity.java @@ -1327,7 +1327,7 @@ public class MainActivity extends Activity public CloudSave cloudSave = null; public ProgressDialog loadingDialog = null; - private FrameLayout _videoLayout = null; + FrameLayout _videoLayout = null; private EditText _screenKeyboard = null; private String _screenKeyboardHintMessage = null; static boolean keyboardWithoutTextInputShown = false; diff --git a/project/jni/application/android_debug.h b/project/jni/application/android_debug.h index 6b535fb66..cab60d0a9 100644 --- a/project/jni/application/android_debug.h +++ b/project/jni/application/android_debug.h @@ -1,7 +1,11 @@ #ifndef __ANDROID_DEBUG_H__ #define __ANDROID_DEBUG_H__ +// Redirect printf() to Android log +// Put this file into CFLAGS: "-include ../android_debug.h" + #include +#include #include #ifdef __cplusplus @@ -46,4 +50,20 @@ namespace std #define printf(...) __android_log_print(ANDROID_LOG_INFO, "SDL-app", __VA_ARGS__) +// Override fprintf(stderr, ...) constructs +static inline int __sdl_logged_fprintf(FILE *stream, const char *format, ...) +{ + int ret = 0; + va_list args; + va_start(args, format); + if( stream == stderr || stream == stdout ) + ret = __android_log_vprint(ANDROID_LOG_INFO, "SDL-app", format, args); + else + ret = vfprintf(stream, format, args); + va_end(args); + return ret; +} + +#define fprintf(...) __sdl_logged_fprintf(__VA_ARGS__) + #endif diff --git a/project/jni/application/hid-pc-keyboard/src b/project/jni/application/hid-pc-keyboard/src index e019e1193..592aab415 160000 --- a/project/jni/application/hid-pc-keyboard/src +++ b/project/jni/application/hid-pc-keyboard/src @@ -1 +1 @@ -Subproject commit e019e1193e73ba244d6f842aebc3cd4f7e9e7cb3 +Subproject commit 592aab415177b2ab443792ca9bc9b38a4f795302 diff --git a/readme.txt b/readme.txt index 8e4faa162..e4eb0b7fa 100644 --- a/readme.txt +++ b/readme.txt @@ -350,7 +350,7 @@ Quick guide to debug native code ================================ You need compile your app with debug enabled to be able to debug native code: -./build.sh debug + ./build.sh debug To debug your application - launch it, go to "project" dir and launch command ndk-gdb then you can run usual GDB commands, like: @@ -364,6 +364,10 @@ You can also debug by adding extensive logs to your app: __android_log_print(ANDROID_LOG_INFO, "My App", "We somehow reached execution point #224"); and then watching "adb logcat" output. +Android does not print app stdout/stderr streams to logcat, so printf() will not work, +but you can redefine printf() and fprintf(stderr) in your app to write to Android log by adding this to AppCflags: + -include jni/application/android_debug.h + If your application crashed, you should use following steps: 1. Gather the crash report from "adb logcat" - it should contain stack trace, if it does not then you're unlucky,