aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtyom Palvelev <artyompp@google.com>2024-02-14 16:08:15 +0000
committerArtyom Palvelev <artyompp@google.com>2024-02-14 16:12:39 +0000
commit9ac9ebdde4c549ea4b0deec2f9a937b0a604a07d (patch)
tree1201bd3e490dd7669027bb76c28f1836121e0ae7
parente56bed6cb60e16803c2fcfada1de91a23f5443e0 (diff)
downloadgamesdk-9ac9ebdde4c549ea4b0deec2f9a937b0a604a07d.tar.gz
fix InMemoryDexClassLoader issues with old API levels
This CL fixes the rare condition in SDKs before 26 (which do not have InMemoryDexClassLoader). Sometimes, the exception is not triggered during class lookup, so we add an explicit check here. Test: build and run any sample that uses Swappy Bug: 323059686 Change-Id: I0d6dd75d1587ca4588039fe2c14ba749d86f89ff
-rw-r--r--src/common/JNIUtil.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/common/JNIUtil.h b/src/common/JNIUtil.h
index 702e24d0..2907eba6 100644
--- a/src/common/JNIUtil.h
+++ b/src/common/JNIUtil.h
@@ -24,6 +24,7 @@
#include <string>
#include "Log.h"
+#include "system_utils.h"
// The code in this file will dynamically load Java classes from a binary
// resource linked to the library. The binary data is in DEX format, accessible
@@ -145,7 +146,9 @@ static jclass loadClass(JNIEnv* env, jobject activity, const char* name,
classLoaderObj, loadClass, dexLoaderClassName));
env->DeleteLocalRef(dexLoaderClassName);
- if (env->ExceptionCheck() || !imclassloaderClass) {
+ int sdkVersion = gamesdk::GetSystemPropAsInt("ro.build.version.sdk");
+
+ if (env->ExceptionCheck() || !imclassloaderClass || sdkVersion < 26) {
env->ExceptionClear();
// For older SDK versions <26, where InMemoryDexClassLoader is not
// available