Exemplo n.º 1
0
        public static void CopySupportLibs()
        {
            string sdkPath        = GetAndroidSdkPath();
            string supportJarPath = sdkPath +
                                    GPGSUtil.SlashesToPlatformSeparator(
                "/extras/android/support/v4/android-support-v4.jar");
            string supportJarDest =
                GPGSUtil.SlashesToPlatformSeparator("Assets/Plugins/Android/libs/android-support-v4.jar");

            string libProjPath = sdkPath +
                                 GPGSUtil.SlashesToPlatformSeparator(
                "/extras/google/google_play_services/libproject/google-play-services_lib");

            string libProjAM =
                libProjPath + GPGSUtil.SlashesToPlatformSeparator("/AndroidManifest.xml");
            string libProjDestDir = GPGSUtil.SlashesToPlatformSeparator(
                "Assets/Plugins/Android/google-play-services_lib");

            // check that the Google Play Services lib project is there
            if (!System.IO.Directory.Exists(libProjPath) || !System.IO.File.Exists(libProjAM))
            {
                Debug.LogError("Google Play Services lib project not found at: " + libProjPath);
                EditorUtility.DisplayDialog(GPGSStrings.AndroidSetup.LibProjNotFound,
                                            GPGSStrings.AndroidSetup.LibProjNotFoundBlurb, GPGSStrings.Ok);
                return;
            }

            // clear out the destination library project
            GPGSUtil.DeleteDirIfExists(libProjDestDir);

            // Copy Google Play Services library
            FileUtil.CopyFileOrDirectory(libProjPath, libProjDestDir);

            if (!System.IO.File.Exists(supportJarPath))
            {
                // check for the new location
                supportJarPath = sdkPath + GPGSUtil.SlashesToPlatformSeparator(
                    "/extras/android/support/v7/appcompat/libs/android-support-v4.jar");
                Debug.LogError("Android support library v4 not found at: " + supportJarPath);
                if (!System.IO.File.Exists(supportJarPath))
                {
                    EditorUtility.DisplayDialog(GPGSStrings.AndroidSetup.SupportJarNotFound,
                                                GPGSStrings.AndroidSetup.SupportJarNotFoundBlurb, GPGSStrings.Ok);
                    return;
                }
            }

            // create needed directories
            GPGSUtil.EnsureDirExists("Assets/Plugins");
            GPGSUtil.EnsureDirExists("Assets/Plugins/Android");

            // Clear out any stale version of the support jar.
            File.Delete(supportJarDest);

            // Copy Android Support Library
            FileUtil.CopyFileOrDirectory(supportJarPath, supportJarDest);
        }
        public static void CopySupportLibs()
        {
            string sdkPath        = GetAndroidSdkPath();
            string supportJarPath = sdkPath +
                                    GPGSUtil.SlashesToPlatformSeparator(
                "/extras/android/support/v4/android-support-v4.jar");
            string supportJarDest =
                GPGSUtil.SlashesToPlatformSeparator("Assets/Plugins/Android/libs/android-support-v4.jar");

            string libProjPath = sdkPath +
                                 GPGSUtil.SlashesToPlatformSeparator(
                "/extras/google/google_play_services/libproject/google-play-services_lib");

            string libProjAM =
                libProjPath + GPGSUtil.SlashesToPlatformSeparator("/AndroidManifest.xml");
            string libProjDestDir = GPGSUtil.SlashesToPlatformSeparator(
                "Assets/Plugins/Android/google-play-services_lib");

            // check that the Google Play Services lib project is there
            if (!System.IO.Directory.Exists(libProjPath) || !System.IO.File.Exists(libProjAM))
            {
                Debug.LogError("Google Play Services lib project not found at: " + libProjPath);
                EditorUtility.DisplayDialog(GPGSStrings.AndroidSetup.LibProjNotFound,
                                            GPGSStrings.AndroidSetup.LibProjNotFoundBlurb, GPGSStrings.Ok);
                return;
            }

            // check version
            int version = GetGPSVersion(libProjPath);

            if (version < 0)
            {
                Debug.LogError("Google Play Services lib version cannot be found!");
            }
            if (version < PluginVersion.MinGmsCoreVersionCode)
            {
                if (!EditorUtility.DisplayDialog(string.Format(
                                                     GPGSStrings.AndroidSetup.LibProjVerTooOld,
                                                     version, PluginVersion.MinGmsCoreVersionCode),
                                                 GPGSStrings.Ok, GPGSStrings.Cancel))
                {
                    Debug.LogError("Google Play Services lib is too old! " +
                                   " Found version " +
                                   version + " require at least version " +
                                   PluginVersion.MinGmsCoreVersionCode);
                    return;
                }
                Debug.Log("Ignoring the version mismatch and continuing the build.");
            }

            // clear out the destination library project
            GPGSUtil.DeleteDirIfExists(libProjDestDir);

            // Copy Google Play Services library
            FileUtil.CopyFileOrDirectory(libProjPath, libProjDestDir);

            if (!System.IO.File.Exists(supportJarPath))
            {
                // check for the new location
                supportJarPath = sdkPath + GPGSUtil.SlashesToPlatformSeparator(
                    "/extras/android/support/v7/appcompat/libs/android-support-v4.jar");
                Debug.LogError("Android support library v4 not found at: " + supportJarPath);
                if (!System.IO.File.Exists(supportJarPath))
                {
                    EditorUtility.DisplayDialog(GPGSStrings.AndroidSetup.SupportJarNotFound,
                                                GPGSStrings.AndroidSetup.SupportJarNotFoundBlurb, GPGSStrings.Ok);
                    return;
                }
            }

            // create needed directories
            GPGSUtil.EnsureDirExists("Assets/Plugins");
            GPGSUtil.EnsureDirExists("Assets/Plugins/Android");

            // Clear out any stale version of the support jar.
            File.Delete(supportJarDest);

            // Copy Android Support Library
            FileUtil.CopyFileOrDirectory(supportJarPath, supportJarDest);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes static members of the <see cref="GooglePlayGames.GPGSUpgrader"/> class.
        /// </summary>
        static GPGSUpgrader()
        {
            string prevVer = GPGSProjectSettings.Instance.Get(GPGSUtil.LASTUPGRADEKEY, "00000");

            if (prevVer != PluginVersion.VersionKey)
            {
                // if this is a really old version, upgrade to 911 first, then 915
                if (prevVer != PluginVersion.VersionKeyCPP)
                {
                    prevVer = Upgrade911(prevVer);
                }

                prevVer = Upgrade915(prevVer);

                prevVer = Upgrade927Patch(prevVer);

                // there is no migration needed to 920+
                Debug.Log("Upgrading from format version " + prevVer + " to " + PluginVersion.VersionKey);
                prevVer = PluginVersion.VersionKey;
                string msg = GPGSStrings.PostInstall.Text.Replace(
                    "$VERSION",
                    PluginVersion.VersionString);
                EditorUtility.DisplayDialog(GPGSStrings.PostInstall.Title, msg, "OK");
            }

            GPGSProjectSettings.Instance.Set(GPGSUtil.LASTUPGRADEKEY, prevVer);
            GPGSProjectSettings.Instance.Save();

            // clean up duplicate scripts if Unity 5+
            int ver = GPGSUtil.GetUnityMajorVersion();

            if (ver >= 5)
            {
                string[] paths =
                {
                    "Assets/GooglePlayGames",
                    "Assets/Plugins/Android"
                };
                foreach (string p in paths)
                {
                    CleanDuplicates(p);
                }

                // remove support lib from old location.
                string jarFile =
                    "Assets/Plugins/Android/libs/android-support-v4.jar";
                if (File.Exists(jarFile))
                {
                    File.Delete(jarFile);
                }

                // remove the massive play services client lib
                string clientDir = "Assets/Plugins/Android/google-play-services_lib";
                GPGSUtil.DeleteDirIfExists(clientDir);
            }

            // Check that there is a AndroidManifest.xml file
            if (!GPGSUtil.AndroidManifestExists())
            {
                GPGSUtil.GenerateAndroidManifest(false);
            }

            AssetDatabase.Refresh();
        }