Merge pull request #55735 from m4gr3d/add_min_target_sdk_configs
This commit is contained in:
commit
599ae423ba
3 changed files with 64 additions and 7 deletions
|
@ -224,6 +224,10 @@ static const int EXPORT_FORMAT_AAB = 1;
|
||||||
static const char *APK_ASSETS_DIRECTORY = "res://android/build/assets";
|
static const char *APK_ASSETS_DIRECTORY = "res://android/build/assets";
|
||||||
static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/installTime/src/main/assets";
|
static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/installTime/src/main/assets";
|
||||||
|
|
||||||
|
static const int DEFAULT_MIN_SDK_VERSION = 19; // Should match the value in 'platform/android/java/app/config.gradle#minSdk'
|
||||||
|
static const int DEFAULT_TARGET_SDK_VERSION = 30; // Should match the value in 'platform/android/java/app/config.gradle#targetSdk'
|
||||||
|
const String SDK_VERSION_RANGE = vformat("%s,%s,1", DEFAULT_MIN_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION);
|
||||||
|
|
||||||
void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
|
void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
|
||||||
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
|
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
|
||||||
|
|
||||||
|
@ -1691,6 +1695,9 @@ void EditorExportPlatformAndroid::get_export_options(List<ExportOption> *r_optio
|
||||||
|
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,4096,1,or_greater"), 1));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0"));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "version/name"), "1.0"));
|
||||||
|
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/min_sdk", PROPERTY_HINT_RANGE, SDK_VERSION_RANGE), DEFAULT_MIN_SDK_VERSION));
|
||||||
|
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "version/target_sdk", PROPERTY_HINT_RANGE, SDK_VERSION_RANGE), DEFAULT_TARGET_SDK_VERSION));
|
||||||
|
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "org.godotengine.$genname"));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/unique_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "ext.domain.name"), "org.godotengine.$genname"));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name [default if blank]"), ""));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "package/name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name [default if blank]"), ""));
|
||||||
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true));
|
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "package/signed"), true));
|
||||||
|
@ -2022,10 +2029,11 @@ String EditorExportPlatformAndroid::get_apksigner_path() {
|
||||||
bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
|
||||||
String err;
|
String err;
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
const bool custom_build_enabled = p_preset->get("custom_template/use_custom_build");
|
||||||
|
|
||||||
// Look for export templates (first official, and if defined custom templates).
|
// Look for export templates (first official, and if defined custom templates).
|
||||||
|
|
||||||
if (!bool(p_preset->get("custom_template/use_custom_build"))) {
|
if (!custom_build_enabled) {
|
||||||
String template_err;
|
String template_err;
|
||||||
bool dvalid = false;
|
bool dvalid = false;
|
||||||
bool rvalid = false;
|
bool rvalid = false;
|
||||||
|
@ -2184,7 +2192,6 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
|
||||||
|
|
||||||
// Ensure that `Use Custom Build` is enabled if a plugin is selected.
|
// Ensure that `Use Custom Build` is enabled if a plugin is selected.
|
||||||
String enabled_plugins_names = PluginConfigAndroid::get_plugins_names(get_enabled_plugins(p_preset));
|
String enabled_plugins_names = PluginConfigAndroid::get_plugins_names(get_enabled_plugins(p_preset));
|
||||||
bool custom_build_enabled = p_preset->get("custom_template/use_custom_build");
|
|
||||||
if (!enabled_plugins_names.empty() && !custom_build_enabled) {
|
if (!enabled_plugins_names.empty() && !custom_build_enabled) {
|
||||||
valid = false;
|
valid = false;
|
||||||
err += TTR("\"Use Custom Build\" must be enabled to use the plugins.");
|
err += TTR("\"Use Custom Build\" must be enabled to use the plugins.");
|
||||||
|
@ -2212,12 +2219,34 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (int(p_preset->get("custom_template/export_format")) == EXPORT_FORMAT_AAB &&
|
if (int(p_preset->get("custom_template/export_format")) == EXPORT_FORMAT_AAB &&
|
||||||
!bool(p_preset->get("custom_template/use_custom_build"))) {
|
!custom_build_enabled) {
|
||||||
valid = false;
|
valid = false;
|
||||||
err += TTR("\"Export AAB\" is only valid when \"Use Custom Build\" is enabled.");
|
err += TTR("\"Export AAB\" is only valid when \"Use Custom Build\" is enabled.");
|
||||||
err += "\n";
|
err += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check the min sdk version
|
||||||
|
int min_sdk_version = p_preset->get("version/min_sdk");
|
||||||
|
if (min_sdk_version != DEFAULT_MIN_SDK_VERSION && !custom_build_enabled) {
|
||||||
|
valid = false;
|
||||||
|
err += TTR("Changing the \"Min Sdk\" is only valid when \"Use Custom Build\" is enabled.");
|
||||||
|
err += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the target sdk version
|
||||||
|
int target_sdk_version = p_preset->get("version/target_sdk");
|
||||||
|
if (target_sdk_version != DEFAULT_TARGET_SDK_VERSION && !custom_build_enabled) {
|
||||||
|
valid = false;
|
||||||
|
err += TTR("Changing the \"Target Sdk\" is only valid when \"Use Custom Build\" is enabled.");
|
||||||
|
err += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target_sdk_version < min_sdk_version) {
|
||||||
|
valid = false;
|
||||||
|
err += TTR("\"Target Sdk\" version must be greater or equal to \"Min Sdk\" version.");
|
||||||
|
err += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
r_error = err;
|
r_error = err;
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
@ -2878,6 +2907,8 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
|
||||||
String package_name = get_package_name(p_preset->get("package/unique_name"));
|
String package_name = get_package_name(p_preset->get("package/unique_name"));
|
||||||
String version_code = itos(p_preset->get("version/code"));
|
String version_code = itos(p_preset->get("version/code"));
|
||||||
String version_name = p_preset->get("version/name");
|
String version_name = p_preset->get("version/name");
|
||||||
|
String min_sdk_version = itos(p_preset->get("version/min_sdk"));
|
||||||
|
String target_sdk_version = itos(p_preset->get("version/target_sdk"));
|
||||||
String enabled_abi_string = String("|").join(enabled_abis);
|
String enabled_abi_string = String("|").join(enabled_abis);
|
||||||
String sign_flag = should_sign ? "true" : "false";
|
String sign_flag = should_sign ? "true" : "false";
|
||||||
String zipalign_flag = "true";
|
String zipalign_flag = "true";
|
||||||
|
@ -2907,6 +2938,8 @@ Error EditorExportPlatformAndroid::export_project_helper(const Ref<EditorExportP
|
||||||
cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name.
|
cmdline.push_back("-Pexport_package_name=" + package_name); // argument to specify the package name.
|
||||||
cmdline.push_back("-Pexport_version_code=" + version_code); // argument to specify the version code.
|
cmdline.push_back("-Pexport_version_code=" + version_code); // argument to specify the version code.
|
||||||
cmdline.push_back("-Pexport_version_name=" + version_name); // argument to specify the version name.
|
cmdline.push_back("-Pexport_version_name=" + version_name); // argument to specify the version name.
|
||||||
|
cmdline.push_back("-Pexport_version_min_sdk=" + min_sdk_version); // argument to specify the min sdk.
|
||||||
|
cmdline.push_back("-Pexport_version_target_sdk=" + target_sdk_version); // argument to specify the target sdk.
|
||||||
cmdline.push_back("-Pexport_enabled_abis=" + enabled_abi_string); // argument to specify enabled ABIs.
|
cmdline.push_back("-Pexport_enabled_abis=" + enabled_abi_string); // argument to specify enabled ABIs.
|
||||||
cmdline.push_back("-Pplugins_local_binaries=" + local_plugins_binaries); // argument to specify the list of plugins local dependencies.
|
cmdline.push_back("-Pplugins_local_binaries=" + local_plugins_binaries); // argument to specify the list of plugins local dependencies.
|
||||||
cmdline.push_back("-Pplugins_remote_binaries=" + remote_plugins_binaries); // argument to specify the list of plugins remote dependencies.
|
cmdline.push_back("-Pplugins_remote_binaries=" + remote_plugins_binaries); // argument to specify the list of plugins remote dependencies.
|
||||||
|
|
|
@ -103,8 +103,8 @@ android {
|
||||||
applicationId getExportPackageName()
|
applicationId getExportPackageName()
|
||||||
versionCode getExportVersionCode()
|
versionCode getExportVersionCode()
|
||||||
versionName getExportVersionName()
|
versionName getExportVersionName()
|
||||||
minSdkVersion versions.minSdk
|
minSdkVersion getExportMinSdkVersion()
|
||||||
targetSdkVersion versions.targetSdk
|
targetSdkVersion getExportTargetSdkVersion()
|
||||||
//CHUNK_ANDROID_DEFAULTCONFIG_BEGIN
|
//CHUNK_ANDROID_DEFAULTCONFIG_BEGIN
|
||||||
//CHUNK_ANDROID_DEFAULTCONFIG_END
|
//CHUNK_ANDROID_DEFAULTCONFIG_END
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
ext.versions = [
|
ext.versions = [
|
||||||
androidGradlePlugin: '7.0.3',
|
androidGradlePlugin: '7.0.3',
|
||||||
compileSdk : 30,
|
compileSdk : 30,
|
||||||
minSdk : 19, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' value
|
minSdk : 19, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION'
|
||||||
targetSdk : 30, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' value
|
targetSdk : 30, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
|
||||||
buildTools : '30.0.3',
|
buildTools : '30.0.3',
|
||||||
kotlinVersion : '1.5.10',
|
kotlinVersion : '1.5.10',
|
||||||
fragmentVersion : '1.3.6',
|
fragmentVersion : '1.3.6',
|
||||||
|
@ -48,6 +48,30 @@ ext.getExportVersionName = { ->
|
||||||
return versionName
|
return versionName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext.getExportMinSdkVersion = { ->
|
||||||
|
String minSdkVersion = project.hasProperty("export_version_min_sdk") ? project.property("export_version_min_sdk") : ""
|
||||||
|
if (minSdkVersion == null || minSdkVersion.isEmpty()) {
|
||||||
|
minSdkVersion = "$versions.minSdk"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(minSdkVersion)
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
return versions.minSdk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.getExportTargetSdkVersion = { ->
|
||||||
|
String targetSdkVersion = project.hasProperty("export_version_target_sdk") ? project.property("export_version_target_sdk") : ""
|
||||||
|
if (targetSdkVersion == null || targetSdkVersion.isEmpty()) {
|
||||||
|
targetSdkVersion = "$versions.targetSdk"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(targetSdkVersion)
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
return versions.targetSdk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ext.getGodotEditorVersion = { ->
|
ext.getGodotEditorVersion = { ->
|
||||||
String editorVersion = project.hasProperty("godot_editor_version") ? project.property("godot_editor_version") : ""
|
String editorVersion = project.hasProperty("godot_editor_version") ? project.property("godot_editor_version") : ""
|
||||||
if (editorVersion == null || editorVersion.isEmpty()) {
|
if (editorVersion == null || editorVersion.isEmpty()) {
|
||||||
|
|
Loading…
Reference in a new issue