Fix issue causing export to fail with "Could not unzip temporary unaligned APK" error and improve command output logging.

This commit is contained in:
Fredia Huya-Kouadio 2021-04-15 13:26:05 -07:00
parent b8bd648ad9
commit 3a033c44b6

View file

@ -1819,7 +1819,7 @@ public:
p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST;
}
String tmp_export_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport.apk");
String tmp_export_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport." + uitos(OS::get_singleton()->get_unix_time()) + ".apk");
#define CLEANUP_AND_RETURN(m_err) \
{ \
@ -1836,6 +1836,7 @@ public:
List<String> args;
int rv;
String output;
bool remove_prev = p_preset->get("one_click_deploy/clear_previous_install");
String version_name = p_preset->get("version/name");
@ -1853,7 +1854,9 @@ public:
args.push_back("uninstall");
args.push_back(get_package_name(package_name));
err = OS::get_singleton()->execute(adb, args, nullptr, &rv);
output.clear();
err = OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
}
print_line("Installing to device (please wait...): " + devices[p_device].name);
@ -1868,7 +1871,9 @@ public:
args.push_back("-r");
args.push_back(tmp_export_path);
err = OS::get_singleton()->execute(adb, args, nullptr, &rv);
output.clear();
err = OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
if (err || rv != 0) {
EditorNode::add_io_error("Could not install to device.");
CLEANUP_AND_RETURN(ERR_CANT_CREATE);
@ -1885,7 +1890,9 @@ public:
args.push_back(devices[p_device].id);
args.push_back("reverse");
args.push_back("--remove-all");
OS::get_singleton()->execute(adb, args, nullptr, &rv);
output.clear();
OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) {
int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
@ -1896,7 +1903,9 @@ public:
args.push_back("tcp:" + itos(dbg_port));
args.push_back("tcp:" + itos(dbg_port));
OS::get_singleton()->execute(adb, args, nullptr, &rv);
output.clear();
OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
print_line("Reverse result: " + itos(rv));
}
@ -1910,7 +1919,9 @@ public:
args.push_back("tcp:" + itos(fs_port));
args.push_back("tcp:" + itos(fs_port));
err = OS::get_singleton()->execute(adb, args, nullptr, &rv);
output.clear();
err = OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
print_line("Reverse result2: " + itos(rv));
}
} else {
@ -1938,7 +1949,9 @@ public:
args.push_back("-n");
args.push_back(get_package_name(package_name) + "/com.godot.game.GodotApp");
err = OS::get_singleton()->execute(adb, args, nullptr, &rv);
output.clear();
err = OS::get_singleton()->execute(adb, args, &output, &rv, true);
print_verbose(output);
if (err || rv != 0) {
EditorNode::add_io_error("Could not execute on device.");
CLEANUP_AND_RETURN(ERR_CANT_CREATE);
@ -2335,6 +2348,7 @@ public:
return ERR_FILE_CANT_OPEN;
}
String output;
List<String> args;
args.push_back("sign");
args.push_back("--verbose");
@ -2350,7 +2364,9 @@ public:
print_verbose("Signing debug binary using: " + String("\n") + apksigner + " " + join_list(args, String(" ")));
}
int retval;
OS::get_singleton()->execute(apksigner, args, nullptr, &retval);
output.clear();
OS::get_singleton()->execute(apksigner, args, &output, &retval, true);
print_verbose(output);
if (retval) {
EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval));
return ERR_CANT_CREATE;
@ -2368,7 +2384,9 @@ public:
print_verbose("Verifying signed build using: " + String("\n") + apksigner + " " + join_list(args, String(" ")));
}
OS::get_singleton()->execute(apksigner, args, nullptr, &retval);
output.clear();
OS::get_singleton()->execute(apksigner, args, &output, &retval, true);
print_verbose(output);
if (retval) {
EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed.");
return ERR_CANT_CREATE;
@ -2673,7 +2691,7 @@ public:
FileAccess *dst_f = nullptr;
io2.opaque = &dst_f;
String tmp_unaligned_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned.apk");
String tmp_unaligned_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned." + uitos(OS::get_singleton()->get_unix_time()) + ".apk");
#define CLEANUP_AND_RETURN(m_err) \
{ \