// Handles the platform specific differences of executing the generate gradle script, and // creating the dialog responsible for showing the progress of the execution. // Any errors are reported to the console as well. /// <param name="args">Arguments to be passed to the generate gradle script tool.</param> private static void RunGenGradleScript(string args) { // b/35663224 Combine execute-python-exe which handles the windows logic. bool onWindows = UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WindowsEditor; string command = "\"" + Path.Combine(GRADLE_SCRIPT_LOCATION, onWindows ? GENERATE_GRADLE_EXE_WINDOWS : GENERATE_GRADLE_EXE_GENERIC) + "\""; if (!onWindows) { args = command + args; command = CommandLine.FindExecutable("python"); } CommandLineDialog window = CommandLineDialog.CreateCommandLineDialog( "Resolving Jars."); window.modal = false; window.summaryText = "Generating and running Gradle prebuild."; window.progressTitle = window.summaryText; window.autoScrollToBottom = true; window.RunAsync( command, args, (result) => { if (result.exitCode != 0) { Debug.LogError("Error somewhere in the process of creating the gradle build, " + "executing it, and copying the outputs.\n" + "This will break dependency resolution and your build will not run.\n" + "See the output below for possible gradle build errors. The most likely " + "cases are: an invalid bundleID (which you can correct in the Android " + "Player Settings), or a failure to determine the Android SDK platform " + "and build tools verison (you can verify that you have a valid android " + "SDK path in the Unity preferences.\n" + "If you're not able to diagnose the error, please report a bug at: " + "https://github.com/googlesamples/unity-jar-resolver/issues" + "A possible work-around is to turn off the " + "\"Gradle Prebuild\" from the Jar Resolver Settings.\n\n" + "Error (" + result.exitCode + "):\n" + result.stdout + result.stderr); window.bodyText += "\n\nResolution Failed."; } else { window.bodyText += "\n\nResolution Complete."; } window.noText = "Close"; // After adding the button we need to scroll down a little more. window.scrollPosition.y = Mathf.Infinity; window.Repaint(); window.buttonClicked = (TextAreaDialog dialog) => { if (!dialog.result) { window.Close(); } }; }, maxProgressLines: 50); window.Show(); }
/// <summary> /// Get the set of available SDK packages and whether they're installed. /// </summary> /// <param name="androidTool">Path to the Android SDK manager tool.</param> /// <param name="svcSupport">PlayServicesSupport instance used to retrieve the SDK /// path.</param> /// <param name="packages">Delegate called with a dictionary of package names and whether /// they're installed or null if the Android SDK isn't configured correctly.</param> internal static void GetAvailablePackages( string androidTool, PlayServicesSupport svcSupport, GetAvailablePackagesComplete complete) { CommandLineDialog window = CommandLineDialog.CreateCommandLineDialog( "Get Installed Android SDK packages."); window.modal = false; window.summaryText = "Getting list of installed Android packages."; window.progressTitle = window.summaryText; window.autoScrollToBottom = true; window.RunAsync( androidTool, "list sdk -u -e -a", (result) => { window.Close(); if (result.exitCode != 0) { Debug.LogError("Unable to determine which Android packages are " + "installed. Failed to run " + androidTool + ". " + result.stderr + " (" + result.exitCode.ToString() + ")"); complete(null); return; } Dictionary <string, bool> packages = new Dictionary <string, bool>(); string[] lines = Regex.Split(result.stdout, "\r\n|\r|\n"); string packageIdentifier = null; foreach (string line in lines) { // Find the start of a package description. Match match = Regex.Match(line, "^id:\\W+\\d+\\W+or\\W+\"([^\"]+)\""); if (match.Success) { packageIdentifier = match.Groups[1].Value; packages[packageIdentifier] = false; continue; } if (packageIdentifier == null) { continue; } // Parse the install path and record whether the package is installed. match = Regex.Match(line, "^\\W+Install[^:]+:\\W+([^ ]+)"); if (match.Success) { packages[packageIdentifier] = File.Exists( Path.Combine(Path.Combine(svcSupport.SDK, match.Groups[1].Value), "source.properties")); packageIdentifier = null; } } complete(packages); }, maxProgressLines: 50); window.Show(); }