diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 017695ce45..d1fa581955 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -583,6 +583,11 @@ if (APPLE) ${IOB_LIBRARY} ${IOK_LIBRARY} ) +elseif (ANDROID) + target_link_libraries(core + PRIVATE + androidcommon + ) endif() if(LIBUSB_FOUND) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 36b750c140..14b7660314 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -85,6 +85,10 @@ #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoConfig.h" +#ifdef ANDROID +#include "jni/AndroidCommon/IDCache.h" +#endif + namespace Core { static bool s_wants_determinism; @@ -335,6 +339,12 @@ static void CpuThread(const std::optional& savestate_path, bool del // This needs to be delayed until after the video backend is ready. DolphinAnalytics::Instance().ReportGameStart(); +#ifdef ANDROID + // For some reason, calling the JNI function AttachCurrentThread from the CPU thread after a + // certain point causes a crash if fastmem is enabled. Let's call it early to avoid that problem. + static_cast(IDCache::GetEnvForThread()); +#endif + if (_CoreParameter.bFastmem) EMM::InstallExceptionHandler(); // Let's run under memory watch