/// Provide static access to setup for facilitating automated builds. /// <param name="nearbyServiceId">The nearby connections service Id</param> /// <param name="androidBuild">true if building android</param> public static bool PerformSetup(string nearbyServiceId, bool androidBuild) { // check for valid app id if (!GPGSUtil.LooksLikeValidServiceId(nearbyServiceId)) { GPGSUtil.Alert(GPGSStrings.Setup.ServiceIdError); return(false); } GPGSProjectSettings.Instance.Set(GPGSUtil.SERVICEIDKEY, nearbyServiceId); GPGSProjectSettings.Instance.Save(); if (androidBuild) { // create needed directories GPGSUtil.EnsureDirExists("Assets/SGLib/Plugins"); GPGSUtil.EnsureDirExists("Assets/SGLib/Plugins/Android"); GPGSUtil.CopySupportLibs(); // Generate AndroidManifest.xml GPGSUtil.GenerateAndroidManifest(false); // refresh assets, and we're done AssetDatabase.Refresh(); GPGSProjectSettings.Instance.Set("android.NearbySetupDone", true); GPGSProjectSettings.Instance.Save(); } return(true); }
/// Provide static access to setup for facilitating automated builds. public static void PerformSetup(string nearbyServiceId) { // check for valid app id if (!GPGSUtil.LooksLikeValidServiceId(nearbyServiceId)) { GPGSUtil.Alert(GPGSStrings.Setup.ServiceIdError); return; } GPGSProjectSettings.Instance.Set(GPGSUtil.SERVICEIDKEY, nearbyServiceId); GPGSProjectSettings.Instance.Save(); // create needed directories GPGSUtil.EnsureDirExists("Assets/Plugins"); GPGSUtil.EnsureDirExists("Assets/Plugins/Android"); GPGSUtil.CopySupportLibs(); // Generate AndroidManifest.xml GPGSUtil.GenerateAndroidManifest(); // refresh assets, and we're done AssetDatabase.Refresh(); GPGSProjectSettings.Instance.Set("android.NearbySetupDone", true); GPGSProjectSettings.Instance.Save(); EditorUtility.DisplayDialog(GPGSStrings.Success, GPGSStrings.NearbyConnections.SetupComplete, GPGSStrings.Ok); }
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); }