// Must be run *without* the -quit option static void ResolveDependencies() { string[] args = System.Environment.GetCommandLineArgs(); if (System.Array.IndexOf(args, "-quit") > -1 || System.Array.IndexOf(args, "-nographcis") > -1) { Debug.LogError("[teak-unity-cleanroom] ResolveDependencies must be run without the '-quit' or '-nographics' options."); EditorApplication.Exit(1); } EditorPrefs.SetString("AndroidSdkRoot", System.Environment.GetEnvironmentVariable("ANDROID_HOME")); EditorPrefs.SetString("AndroidNdkRoot", System.Environment.GetEnvironmentVariable("ANDROID_NDK_HOME")); Debug.Log("[teak-unity-cleanroom] Resolving dependencies with Play Services Resolver"); PlayServicesResolver.Resolve( resolutionCompleteWithResult: (success) => { if (!success) { Debug.Log("[teak-unity-cleanroom] FAILED to resolve dependencies"); EditorApplication.Exit(1); } else { Debug.Log("[teak-unity-cleanroom] Resolved dependencies"); EditorApplication.Exit(0); } }, forceResolution: false); }
public static void BuildAPK(bool alsoRunIt) { EditorUserBuildSettings.buildAppBundle = false; PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x); PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7; PlayServicesResolver.Resolve(() => { UpdateVersion(); BuildOptions options = alsoRunIt ? BuildOptions.None | BuildOptions.AutoRunPlayer : BuildOptions.None; var version = $"{Application.version}"; var filePath = GetAndroidBuildPath(version); Build(options, filePath); }); }
public static void BuildAAB() { EditorUserBuildSettings.buildAppBundle = true; PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP); PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64 | AndroidArchitecture.ARMv7; PlayerSettings.Android.bundleVersionCode++; PlayServicesResolver.Resolve(() => { UpdateVersion(); BuildOptions options = BuildOptions.None; var version = $"{Application.version}"; var filePath = GetAndroidBuildPath(version, true); Build(options, filePath); }); }
private static void PrepareResolver() { // Force playServices Resolver PlayServicesResolver.Resolve(null, true); }
/// <summary> /// Asynchronously run the Android Resolver and validate the result with /// ValidateAndroidResolution. /// </summary> /// <param name="androidBuildSystem">Android build system to select.</param> /// <param name="exportProject">Whether Android project export should be enabled.</param> /// <param name="expectedAssetsDir">Directory that contains the assets expected from the /// resolution step.</param> /// <param name="targetAbis">String of Android ABIs to target or null if the default ABIs /// should be selected.</param> /// <param name="filesToIgnore">Set of files to relative to the generatedAssetsDir.</param> /// <param name="testCase">Object executing this method.</param> /// <param name="testCaseComplete">Called with the test result.</param> /// <param name="synchronous">Whether the resolution should be executed synchronously.</param> private static void Resolve(string androidBuildSystem, bool exportProject, string expectedAssetsDir, string targetAbis, ICollection <string> filesToIgnore, IntegrationTester.TestCase testCase, Action <IntegrationTester.TestCaseResult> testCaseComplete, bool synchronous = false) { // Set the Android target ABIs. GooglePlayServices.AndroidAbis.CurrentString = targetAbis; // Try setting the build system if this version of Unity supports it. if (!GradleBuildSupported && androidBuildSystem == "Gradle") { testCaseComplete(new IntegrationTester.TestCaseResult(testCase) { Skipped = true, ErrorMessages = new List <string> { "Unity version does not support Gradle builds." } }); return; } if (!(SetEditorUserBuildSettingsProperty( ANDROID_BUILD_SYSTEM, StringToAndroidBuildSystemValue(androidBuildSystem)) && GetEditorUserBuildSettingsProperty( ANDROID_BUILD_SYSTEM, androidBuildSystem).ToString() == androidBuildSystem)) { testCaseComplete(new IntegrationTester.TestCaseResult(testCase) { ErrorMessages = new List <string> { String.Format("Unable to set AndroidBuildSystem to {0}.", androidBuildSystem) } }); return; } // Configure project export setting. if (!(SetEditorUserBuildSettingsProperty(EXPORT_ANDROID_PROJECT, exportProject) && (bool)GetEditorUserBuildSettingsProperty(EXPORT_ANDROID_PROJECT, exportProject) == exportProject)) { testCaseComplete(new IntegrationTester.TestCaseResult(testCase) { ErrorMessages = new List <string> { String.Format("Unable to set Android export project to {0}.", exportProject) } }); } // Resolve dependencies. Action <bool> completeWithResult = (bool complete) => { IntegrationTester.Runner.ExecuteTestCase( testCase, () => { testCaseComplete(new IntegrationTester.TestCaseResult(testCase) { ErrorMessages = ValidateAndroidResolution(expectedAssetsDir, complete, filesToIgnore) }); }, true); }; if (synchronous) { bool success = PlayServicesResolver.ResolveSync(true); completeWithResult(success); } else { PlayServicesResolver.Resolve(resolutionCompleteWithResult: completeWithResult); } }