1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-31 02:35:46 +01:00

Merge pull request #20894 from janisozaur/android-fix-0.4.6

Fix Android startup code
This commit is contained in:
Michał Janiszewski
2023-10-18 00:10:30 +02:00
committed by GitHub
3 changed files with 18 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
- Fix: [#18199] Dots in the game save's name no longer get truncated.
- Fix: [#19722] “Forbid tree removal” restriction doesn't forbid removal of large scenery tree items.
- Fix: [#20356] Cannot set tertiary colour on small scenery.
- Fix: [#20679] Android: game crashes at launch.
- Fix: [#20737] Spent money in player window underflows when getting refunds.
- Fix: [#20778] [Plugin] Incorrect target api when executing custom actions.
- Fix: [#20807] Tertiary colour not copied with small scenery.

View File

@@ -18,3 +18,4 @@
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4096m

View File

@@ -27,7 +27,9 @@ AndroidClassLoader::~AndroidClassLoader()
jobject AndroidClassLoader::_classLoader;
jmethodID AndroidClassLoader::_findClassMethod;
static std::shared_ptr<AndroidClassLoader> acl = std::make_shared<AndroidClassLoader>();
// Initialized in JNI_OnLoad. Cannot be initialized here as JVM is not
// available until after JNI_OnLoad is called.
static std::shared_ptr<AndroidClassLoader> acl;
namespace Platform
{
@@ -181,6 +183,19 @@ namespace Platform
}
} // namespace Platform
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* pjvm, void* reserved)
{
// Due to an issue where JNI_OnLoad could be called multiple times, we need
// to make sure it is only initialized once.
// https://issuetracker.google.com/issues/220523932
// Otherwise JVM complains about jobject-s having incorrect serial numbers.
if (!acl)
{
acl = std::make_shared<AndroidClassLoader>();
}
return JNI_VERSION_1_6;
}
AndroidClassLoader::AndroidClassLoader()
{
LOG_INFO("Obtaining JNI class loader");