From d45b96d2b151d965e0bd536abf7cc17a1ff84da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 15 May 2020 11:43:42 +0200 Subject: [PATCH] Android: Check for deprecated GodotPaymentV3 module, direct to new plugin Fixes #38581. --- .gitignore | 3 ++- doc/classes/Engine.xml | 2 +- doc/classes/ProjectSettings.xml | 3 ++- platform/android/export/export.cpp | 14 ++++++++++++++ platform/android/java_godot_lib_jni.cpp | 7 +++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9b68510bb3e..0a4c849007e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,9 @@ local.properties .idea .gradletasknamecache project.properties -platform/android/java/libs/* platform/android/java/app/libs/* +platform/android/java/libs/* +platform/android/java/lib/.cxx/ # General c++ generated files *.lib diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 5ec723645f7..54d637e46df 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -99,7 +99,7 @@ - Returns a global singleton with given [code]name[/code]. Often used for plugins, e.g. GodotPayments. + Returns a global singleton with given [code]name[/code]. Often used for plugins, e.g. [code]GodotPayment[/code] on Android. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 1b09f2d45be..d37c9df3ed0 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -180,7 +180,8 @@ - Comma-separated list of custom Android modules (which must have been built in the Android export templates) using their Java package path, e.g. [code]org/godotengine/org/GodotPaymentV3,org/godotengine/godot/MyCustomSingleton"[/code]. + Comma-separated list of custom Android modules (which must have been built in the Android export templates) using their Java package path, e.g. [code]"org/godotengine/godot/MyCustomSingleton,com/example/foo/FrenchFriesFactory"[/code]. + [b]Note:[/b] Since Godot 3.2.2, the [code]org/godotengine/godot/GodotPaymentV3[/code] module was deprecated and replaced by the [code]GodotPayment[/code] plugin which should be enabled in the Android export preset by adding [code]GodotPayment[/code] to the [code]custom_template/plugins[/code] option. The singleton to access in code was also renamed to [code]GodotPayment[/code]. Background color for the boot splash. diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8ebb02692eb..528b6083a01 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1777,6 +1777,20 @@ public: err += etc_error; } + // The GodotPaymentV3 module was converted to the GodotPayment plugin in Godot 3.2.2, + // this check helps users to notice the change to ensure that they change their settings. + String modules = ProjectSettings::get_singleton()->get("android/modules"); + if (modules.find("org/godotengine/godot/GodotPaymentV3") != -1) { + String plugins = p_preset->get("custom_template/plugins"); + if (plugins.split(",", false).find("GodotPayment") == -1) { + valid = false; + err += TTR("Invalid \"GodotPaymentV3\" module included in the \"android/modules\" project setting (changed in Godot 3.2.2).\n" + "Replace it by the \"GodotPayment\" plugin, which should be listed in the \"custom_template/plugins\" preset option.\n" + "Note that the singleton was also renamed from \"GodotPayments\" to \"GodotPayment\"."); + err += "\n"; + } + } + r_error = err; return valid; } diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index c83febe0267..8bbbfe73a63 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -91,6 +91,13 @@ static void _initialize_java_modules() { String m = mods[i]; + // Deprecated in Godot 3.2.2, it's now a plugin to enable in export preset. + if (m == "org/godotengine/godot/GodotPaymentV3") { + WARN_PRINT("GodotPaymentV3 is deprecated and is replaced by the 'GodotPayment' plugin, which should be enabled in the Android export preset."); + print_line("Skipping Android module: " + m); + continue; + } + print_line("Loading Android module: " + m); jstring strClassName = env->NewStringUTF(m.utf8().get_data()); jclass singletonClass = (jclass)env->CallObjectMethod(cls, findClass, strClassName);