diff --git a/core/src/main/cpp/main/include/jni_helper.h b/core/src/main/cpp/main/include/jni_helper.h index bf9135dc..47326b4a 100644 --- a/core/src/main/cpp/main/include/jni_helper.h +++ b/core/src/main/cpp/main/include/jni_helper.h @@ -156,9 +156,10 @@ concept ScopeOrObject = ScopeOrRaw; inline ScopedLocalRef ClearException(JNIEnv *env) { if (auto exception = env->ExceptionOccurred()) { env->ExceptionClear(); - static jmethodID toString = env->GetMethodID(env->FindClass("java/lang/Object"), "toString", - "()Ljava/lang/String;"); - auto str = (jstring) env->CallObjectMethod(exception, toString); + static jclass log = (jclass) env->NewGlobalRef(env->FindClass("android/util/Log")); + static jmethodID toString = env->GetStaticMethodID(log, "getStackTraceString", + "(Ljava/lang/Throwable;)Ljava/lang/String;"); + auto str = (jstring) env->CallStaticObjectMethod(log, toString, exception); env->DeleteLocalRef(exception); return {env, str}; }