Skip to content

Commit

Permalink
Fixed Android export failing when no JDK is setup in the OS environme…
Browse files Browse the repository at this point in the history
…nt and custom keystores have been set in the export dialog.
  • Loading branch information
ChrisBase committed Jul 26, 2024
1 parent 607b230 commit d4912ed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ String EditorExportPlatformAndroid::get_apksigner_path(int p_target_sdk, bool p_
return apksigner_path;
}

static bool has_valid_keystore_credentials(String &r_error_str, const String &p_keystore, const String &p_username, const String &p_password, const String &p_type) {
static bool has_valid_keystore_credentials(String &r_error_str, const String &p_keytool, const String &p_keystore, const String &p_username, const String &p_password, const String &p_type) {
String output;
List<String> args;
args.push_back("-list");
Expand All @@ -2323,7 +2323,7 @@ static bool has_valid_keystore_credentials(String &r_error_str, const String &p_
args.push_back(p_password);
args.push_back("-alias");
args.push_back(p_username);
Error error = OS::get_singleton()->execute("keytool", args, &output, nullptr, true);
Error error = OS::get_singleton()->execute(p_keytool, args, &output, nullptr, true);
String keytool_error = "keytool error:";
bool valid = output.substr(0, keytool_error.length()) != keytool_error;

Expand All @@ -2340,6 +2340,7 @@ static bool has_valid_keystore_credentials(String &r_error_str, const String &p_
}

bool EditorExportPlatformAndroid::has_valid_username_and_password(const Ref<EditorExportPreset> &p_preset, String &r_error) {
String keytool = get_keytool_path();
String dk = _get_keystore_path(p_preset, true);
String dk_user = p_preset->get_or_env("keystore/debug_user", ENV_ANDROID_KEYSTORE_DEBUG_USER);
String dk_password = p_preset->get_or_env("keystore/debug_password", ENV_ANDROID_KEYSTORE_DEBUG_PASS);
Expand All @@ -2350,12 +2351,12 @@ bool EditorExportPlatformAndroid::has_valid_username_and_password(const Ref<Edit
bool valid = true;
if (!dk.is_empty() && !dk_user.is_empty() && !dk_password.is_empty()) {
String err = "";
valid = has_valid_keystore_credentials(err, dk, dk_user, dk_password, "Debug");
valid = has_valid_keystore_credentials(err, keytool, dk, dk_user, dk_password, "Debug");
r_error += err;
}
if (!rk.is_empty() && !rk_user.is_empty() && !rk_password.is_empty()) {
String err = "";
valid = has_valid_keystore_credentials(err, rk, rk_user, rk_password, "Release");
valid = has_valid_keystore_credentials(err, keytool, rk, rk_user, rk_password, "Release");
r_error += err;
}
return valid;
Expand Down

0 comments on commit d4912ed

Please sign in to comment.