Index: cpp/frams/util/sstring-simple.cpp
===================================================================
--- cpp/frams/util/sstring-simple.cpp	(revision 896)
+++ cpp/frams/util/sstring-simple.cpp	(revision 897)
@@ -268,4 +268,27 @@
 		va_end(ap);
 		/* If that worked, return the string. */
+
+#ifdef __ANDROID__
+		//Workaround for Android bug. /system/lib64/libc.so? maybe only arm 64-bit? "If an encoding error occurs, a negative number is returned". On some devices keeps returning -1 forever.
+		//https://github.com/android-ndk/ndk/issues/879 but unfortunately during google play tests (Firebase Test Lab) this problem turned out to be not limited to Chinese devices and occurred in Mate 9, Galaxy S9, Pixel, Pixel 2, Moto Z (even with the en_GB locale; the locale is not important but the problem seem to be utf8 non-ascii chars in the format string).
+		if (n < 0 && size >= (1 << 24)) //wants more than 16M
+		{
+			buf[size - 1] = 0; //just to ensure there is at least some ending \0 in memory... who knows what buggy vsnprintf() did.
+			__android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, "Giving up due to Android bug: vsnprintf() wants more than %d bytes, it used %zu bytes, for format='%s'", size, strlen(buf), format);
+			//in my tests, it always used 0 bytes, so it produced a 0-length string: ""
+			va_copy(ap_copy, ap);
+			n = vsprintf(buf, format, ap_copy); //hoping 16M is enough
+			va_end(ap_copy);
+			__android_log_print(ANDROID_LOG_INFO, LOG_APP_NAME, "Fallback to vsprintf() produced string: '%s'", buf);
+			if (n < 0) //vsprintf was also buggy. If we were strict, we should abort the app now.
+			{
+				strcpy(buf, "[STR_ERR] "); //a special prefix just to indicate the returned string is incorrect
+				strcat(buf, format); //append and return the original formatting string
+				__android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, "vsprintf() also failed, using the incorrect resulting string: '%s'", buf);
+			}
+			n = strlen(buf); //pretend vsnprintf() or vsprintf() was OK to exit the endless loop
+		}
+#endif
+
 		if (n > -1 && n < size)
 		{
Index: cpp/frams/util/sstring.cpp
===================================================================
--- cpp/frams/util/sstring.cpp	(revision 896)
+++ cpp/frams/util/sstring.cpp	(revision 897)
@@ -415,4 +415,27 @@
 		va_end(ap);
 		/* If that worked, return the string. */
+
+#ifdef __ANDROID__
+		//Workaround for Android bug. /system/lib64/libc.so? maybe only arm 64-bit? "If an encoding error occurs, a negative number is returned". On some devices keeps returning -1 forever.
+		//https://github.com/android-ndk/ndk/issues/879 but unfortunately during google play tests (Firebase Test Lab) this problem turned out to be not limited to Chinese devices and occurred in Mate 9, Galaxy S9, Pixel, Pixel 2, Moto Z (even with the en_GB locale; the locale is not important but the problem seem to be utf8 non-ascii chars in the format string).
+		if (n < 0 && size >= (1 << 24)) //wants more than 16M
+		{
+			buf[size - 1] = 0; //just to ensure there is at least some ending \0 in memory... who knows what buggy vsnprintf() did.
+			__android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, "Giving up due to Android bug: vsnprintf() wants more than %d bytes, it used %zu bytes, for format='%s'", size, strlen(buf), format);
+			//in my tests, it always used 0 bytes, so it produced a 0-length string: ""
+			va_copy(ap_copy, ap);
+			n = vsprintf(buf, format, ap_copy); //hoping 16M is enough
+			va_end(ap_copy);
+			__android_log_print(ANDROID_LOG_INFO, LOG_APP_NAME, "Fallback to vsprintf() produced string: '%s'", buf);
+			if (n < 0) //vsprintf was also buggy. If we were strict, we should abort the app now.
+			{
+				strcpy(buf, "[STR_ERR] "); //a special prefix just to indicate the returned string is incorrect
+				strcat(buf, format); //append and return the original formatting string
+				__android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, "vsprintf() also failed, using the incorrect resulting string: '%s'", buf);
+			}
+			n = strlen(buf); //pretend vsnprintf() or vsprintf() was OK to exit the endless loop
+		}
+#endif
+
 		if (n > -1 && n < size)
 		{
