private static void CheckAnt(XmlNode node, string ant_path)
        {
            Debug.Log("Check Ant...");
            string min_version = node.Attributes["min-version"].Value;

            var    ant_exec = Ant.getAntFormAntSDK(ant_path);
            string output   = Exec.RunGetOutput(ant_exec.FullName, "-version", true);

            string[] words = output.Split(' ');

            Delegate <string> find_version_word = () =>
            {
                foreach (var w in words)
                {
                    if (w.Contains("."))
                    {
                        return(w);
                    }
                }
                return(null);
            };
            string version_word = find_version_word();

            Version targetVersion = new Version(min_version);
            Version myVersion     = new Version(version_word);

            if (myVersion < targetVersion)
            {
                throw new AssertException("Ant version need '" + min_version + "' or heigher, now is " + version_word + "(use 'ant -version' to check).");
            }
        }
Beispiel #2
0
        public static void RunAPK(string apkPath, string package, string androidSdkPath)
        {
            // find adb
            var ADB   = OSUtil.Platform == Platform.Mac ? "adb" : "adb.exe";
            var files = new DirectoryInfo(androidSdkPath).GetFiles(ADB, SearchOption.AllDirectories);

            if (files.Length == 0)
            {
                throw new IOException("adb not found in '" + androidSdkPath + "'!");
            }
            FileInfo adb = files[0];

            // adb device
            if (!HasDevices(androidSdkPath))
            {
                throw new Exception("No Device Connected, Running task canceled");
            }
            // adb install
            string s = Exec.RunGetOutput(adb.FullName, "install -r " + apkPath, true);

            if (s.Contains("Failure"))
            {
                throw new Exception("Error in adb install");
            }
            // adb monkey
            var code2 = Exec.Run(adb.FullName, "shell monkey -p " + package + " -v 1");

            if (code2 != 0)
            {
                throw new Exception("Error in adb monkey");
            }
        }
Beispiel #3
0
        public static string android_list_target(string android_sdk_path)
        {
            FileInfo android;
            {
                var di = new DirectoryInfo(android_sdk_path);
                if (!di.Exists)
                {
                    throw new IOException("android sdk not exsists!");
                }
                var ANDROID = OSUtil.Platform == Platform.Mac ? "android" : "android.bat";
                var files   = di.GetFiles(ANDROID, SearchOption.AllDirectories);
                if (files.Length == 0)
                {
                    throw new IOException("None '" + ANDROID + "' was found in adnroid sdk");
                }
                else if (files.Length > 1)
                {
                    UnityEngine.Debug.Log("Mutiple '" + ANDROID + "' was found, use this one: " + files[0].FullName);
                }
                android = files[0];
            }

            var output = Exec.RunGetOutput(android.FullName, "list target", true);

            return(output);
        }
        private static void CheckJdk(XmlNode node)
        {
            Debug.Log("Check JDK...");
            string min_version = node.Attributes["min-version"].Value;

            string output       = Exec.RunGetOutput("java", "-version", true);
            string firstLine    = output.Substring(0, output.IndexOf("\n"));
            int    s            = firstLine.IndexOf("\"");
            int    e            = firstLine.LastIndexOf("\"");
            string version_name = firstLine.Substring(s + 1, e - s - 1);

            if (version_name.Contains("_"))
            {
                version_name = version_name.Substring(0, version_name.IndexOf("_"));
            }

            Version targetVersion = new Version(min_version);
            Version myVersion     = new Version(version_name);

            if (myVersion < targetVersion)
            {
                throw new AssertException("Java version need '" + min_version + "' or higher, now is: " + version_name + "(miss JAVA_HOME?. use 'java -version' to check version).");
            }
        }
Beispiel #5
0
        public static bool HasDevices(string androidSdkPath)
        {
            // find adb
            var ADB   = OSUtil.Platform == Platform.Mac ? "adb" : "adb.exe";
            var files = new DirectoryInfo(androidSdkPath).GetFiles(ADB, SearchOption.AllDirectories);

            if (files.Length == 0)
            {
                throw new IOException("adb not found in '" + androidSdkPath + "'!");
            }
            FileInfo adb = files[0];

            // adb device
            string s = Exec.RunGetOutput(adb.FullName, " devices");

            s = s.Substring(s.IndexOf("List of devices attached"));
            s = s.Substring(24);
            UnityEngine.Debug.Log("get string from 'devices': " + s);
            if (s == null || !s.Contains("device") || s.Contains("error") || s.Contains("waiting for device") || s.Contains("*"))
            {
                return(false);
            }
            return(true);
        }