Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.4] Android: Only warn when Target SDK is non default #62609

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6995,6 +6995,8 @@ EditorNode::EditorNode() {
execute_output_dialog = memnew(AcceptDialog);
execute_output_dialog->add_child(execute_outputs);
execute_output_dialog->set_title("");
// Prevent closing too fast and missing important information.
execute_output_dialog->set_exclusive(true);
gui_base->add_child(execute_output_dialog);

EditorFileSystem::get_singleton()->connect("sources_changed", this, "_sources_changed");
Expand Down
21 changes: 20 additions & 1 deletion editor/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ void ProjectExportDialog::_edit_preset(int p_index) {
}
error += " - " + items[i];
}

export_error->set_text(error);
export_error->show();
} else {
export_error->hide();
}
export_warning->hide();
if (needs_templates) {
export_templates_error->show();
} else {
Expand All @@ -262,6 +262,20 @@ void ProjectExportDialog::_edit_preset(int p_index) {
get_ok()->set_disabled(true);

} else {
if (error != String()) {
Vector<String> items = error.split("\n", false);
error = "";
for (int i = 0; i < items.size(); i++) {
if (i > 0) {
error += "\n";
}
error += " - " + items[i];
}
export_warning->set_text(error);
export_warning->show();
} else {
export_warning->hide();
}
export_error->hide();
export_templates_error->hide();
export_button->set_disabled(false);
Expand Down Expand Up @@ -1144,6 +1158,11 @@ ProjectExportDialog::ProjectExportDialog() {
export_error->hide();
export_error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor"));

export_warning = memnew(Label);
main_vb->add_child(export_warning);
export_warning->hide();
export_warning->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("warning_color", "Editor"));

export_templates_error = memnew(HBoxContainer);
main_vb->add_child(export_templates_error);
export_templates_error->hide();
Expand Down
1 change: 1 addition & 0 deletions editor/project_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class ProjectExportDialog : public ConfirmationDialog {
Label *script_key_error;

Label *export_error;
Label *export_warning;
HBoxContainer *export_templates_error;

String default_filename;
Expand Down
32 changes: 23 additions & 9 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static const char *AAB_ASSETS_DIRECTORY = "res://android/build/assetPacks/instal

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 = 31; // 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);
const String SDK_VERSION_RANGE = vformat("%s,%s,1,or_greater", DEFAULT_MIN_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION + 1);

void EditorExportPlatformAndroid::_check_for_changes_poll_thread(void *ud) {
EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
Expand Down Expand Up @@ -2249,20 +2249,34 @@ bool EditorExportPlatformAndroid::can_export(const Ref<EditorExportPreset> &p_pr
err += "\n";
}

// Check the min sdk version
// Check the min and target sdk version.

// They're only used for custom_build_enabled, but since we save their default values
// in the export preset, users would get an unexpected error when updating to a Godot
// version that has different values (GH-62465).
// So we don't make a blocking error, instead we just show a warning.

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 += vformat(TTR("\"Min Sdk\" was changed from the default \"%d\" to \"%d\". This option requires \"Use Custom Build\" to be enabled.\n>> Change it to \"%d\" to silence this warning, or enable \"Use Custom Build\" to use this min SDK."), DEFAULT_MIN_SDK_VERSION, min_sdk_version, DEFAULT_MIN_SDK_VERSION);
err += "\n";
}

// Check the target sdk version
// Here we also handle compatibility with Godot 3.4 to 3.4.4 where target SDK was 30.
// Version 3.4.5 updated it to 31 to match platform requirements, so make sure that
// users notice it.
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 != DEFAULT_TARGET_SDK_VERSION) {
if (!custom_build_enabled) {
err += vformat(TTR("\"Target Sdk\" was changed from the default \"%d\" to \"%d\". This option requires \"Use Custom Build\" to be enabled.\n>> Change it to \"%d\" to silence this warning, or enable \"Use Custom Build\" to use this target SDK."), DEFAULT_TARGET_SDK_VERSION, target_sdk_version, DEFAULT_TARGET_SDK_VERSION);
err += "\n";
} else if (target_sdk_version == 30) { // Compatibility with < 3.4.5.
err += vformat(TTR("\"Target Sdk\" is set to 30, while the current default is \"%d\". This might be due to upgrading from a previous Godot release.\n>> Consider changing it to \"%d\" to stay up-to-date with platform requirements."), DEFAULT_TARGET_SDK_VERSION, DEFAULT_TARGET_SDK_VERSION);
err += "\n";
} else if (target_sdk_version > DEFAULT_TARGET_SDK_VERSION) {
err += vformat(TTR("\"Target Sdk\" %d is higher than the default version %d. This may work, but wasn't tested and may be unstable."), target_sdk_version, DEFAULT_TARGET_SDK_VERSION);
err += "\n";
}
}

if (target_sdk_version < min_sdk_version) {
Expand Down