From d7e5c8fad5d6f0f50a3cecdf50d2a936c24e78b4 Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Thu, 15 Apr 2021 13:26:05 -0700 Subject: [PATCH] Fix issue causing export to fail with "Could not unzip temporary unaligned APK" error and improve command output logging. --- platform/android/export/export.cpp | 38 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 8ae12b875e8..40caf708e77 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1869,7 +1869,7 @@ public: if (use_reverse) 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) \ { \ @@ -1887,6 +1887,7 @@ public: List 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"); @@ -1904,7 +1905,9 @@ public: args.push_back("uninstall"); args.push_back(get_package_name(package_name)); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + output.clear(); + err = OS::get_singleton()->execute(adb, args, true, NULL, &output, &rv, true); + print_verbose(output); } print_line("Installing to device (please wait...): " + devices[p_device].name); @@ -1919,7 +1922,9 @@ public: args.push_back("-r"); args.push_back(tmp_export_path); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + output.clear(); + err = OS::get_singleton()->execute(adb, args, true, NULL, &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); @@ -1937,7 +1942,9 @@ public: args.push_back(devices[p_device].id); args.push_back("reverse"); args.push_back("--remove-all"); - OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + output.clear(); + OS::get_singleton()->execute(adb, args, true, NULL, &output, &rv, true); + print_verbose(output); if (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) { @@ -1949,7 +1956,9 @@ public: args.push_back("tcp:" + itos(dbg_port)); args.push_back("tcp:" + itos(dbg_port)); - OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + output.clear(); + OS::get_singleton()->execute(adb, args, true, NULL, &output, &rv, true); + print_verbose(output); print_line("Reverse result: " + itos(rv)); } @@ -1964,7 +1973,9 @@ public: args.push_back("tcp:" + itos(fs_port)); args.push_back("tcp:" + itos(fs_port)); - err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); + output.clear(); + err = OS::get_singleton()->execute(adb, args, true, NULL, &output, &rv, true); + print_verbose(output); print_line("Reverse result2: " + itos(rv)); } } else { @@ -1993,7 +2004,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, true, NULL, NULL, &rv); + output.clear(); + err = OS::get_singleton()->execute(adb, args, true, NULL, &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); @@ -2693,6 +2706,7 @@ public: return ERR_FILE_CANT_OPEN; } + String output; List args; args.push_back("sign"); args.push_back("--verbose"); @@ -2708,7 +2722,9 @@ public: print_verbose("Signing debug binary using: " + String("\n") + apksigner + " " + join_list(args, String(" "))); } int retval; - OS::get_singleton()->execute(apksigner, args, true, NULL, NULL, &retval); + output.clear(); + OS::get_singleton()->execute(apksigner, args, true, NULL, &output, &retval, true); + print_verbose(output); if (retval) { EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval)); return ERR_CANT_CREATE; @@ -2726,7 +2742,9 @@ public: print_verbose("Verifying signed build using: " + String("\n") + apksigner + " " + join_list(args, String(" "))); } - OS::get_singleton()->execute(apksigner, args, true, NULL, NULL, &retval); + output.clear(); + OS::get_singleton()->execute(apksigner, args, true, NULL, &output, &retval, true); + print_verbose(output); if (retval) { EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed."); return ERR_CANT_CREATE; @@ -3032,7 +3050,7 @@ public: FileAccess *dst_f = NULL; 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) \ { \