Skip to content

Commit 6641f1e

Browse files
committed
fix android build
1 parent ee1bba3 commit 6641f1e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

native/src/CubismFramework_JNI.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ static csmByte* LoadFile(const std::string filePath, csmSizeInt* outSize) {
2323
bool attached = false;
2424
jint res = g_jvm->GetEnv((void**)&env, JNI_VERSION_1_6);
2525
if (res == JNI_EDETACHED) {
26+
#ifdef __ANDROID__
27+
g_jvm->AttachCurrentThread(&env, nullptr);
28+
#else
2629
g_jvm->AttachCurrentThread((void**)&env, nullptr);
30+
#endif
2731
attached = true;
2832
} else if (res != JNI_OK) {
2933
return nullptr;
@@ -82,7 +86,11 @@ static void LogFunction(const char* message) {
8286
bool attached = false;
8387
jint res = g_jvm->GetEnv((void**)&env, JNI_VERSION_1_6);
8488
if (res == JNI_EDETACHED) {
89+
#ifdef __ANDROID__
90+
g_jvm->AttachCurrentThread(&env, nullptr);
91+
#else
8592
g_jvm->AttachCurrentThread((void**)&env, nullptr);
93+
#endif
8694
attached = true;
8795
} else if (res != JNI_OK) {
8896
return;

scripts/build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def download_sdk():
4040
with open(tpp, "r", encoding="utf-8") as f: content = f.read()
4141
with open(tpp, "w", encoding="utf-8") as f:
4242
f.write(content.replace("_clearedMaskBufferFlags = NULL;", "_clearedMaskBufferFlags.Clear();"))
43+
44+
gles2_hpp = os.path.join(SDK_DIR, "Framework/src/Rendering/OpenGL/CubismRenderer_OpenGLES2.hpp")
45+
with open(gles2_hpp, "r", encoding="utf-8") as f: content = f.read()
46+
content = content.replace("void Initialize(Framework::CubismModel* model, csmInt32 maskBufferCount);",
47+
"void Initialize(Framework::CubismModel* model, csmInt32 maskBufferCount) override;")
48+
content = content.replace("virtual void SaveProfile();", "void SaveProfile() override;")
49+
content = content.replace("virtual void RestoreProfile();", "void RestoreProfile() override;")
50+
with open(gles2_hpp, "w", encoding="utf-8") as f: f.write(content)
4351

4452
def download_headers():
4553
inc_dir = os.path.abspath("native/include")

0 commit comments

Comments
 (0)