public static void Build()
        {
            PlayerSettings.applicationIdentifier = "com.google.android.instantapps.samples.unity.testapp";
            PlayerSettings.companyName           = "Google";
            PlayerSettings.productName           = "testapp";

            CommandLineBuilder.ConfigureProject(TestScenePaths);

            // Build APK.
            var apkPath            = CommandLineBuilder.GetApkPath();
            var buildPlayerOptions = PlayInstantBuilder.CreateBuildPlayerOptions(apkPath, BuildOptions.None);

            if (!PlayInstantBuilder.BuildAndSign(buildPlayerOptions))
            {
                throw new Exception("APK build failed");
            }

            // Also Build an AAB to test Android App Bundle build.
            DownloadBundletoolIfNecessary();
            var aabPath = apkPath.Substring(0, apkPath.Length - 3) + "aab";

            if (!AppBundlePublisher.Build(aabPath))
            {
                throw new Exception("AAB build failed");
            }
        }
        public static void Build()
        {
            PlayerSettings.applicationIdentifier = "com.google.android.instantapps.samples.unity.testapp";
            PlayerSettings.companyName           = "Google";
            PlayerSettings.productName           = "testapp";

            CommandLineBuilder.ConfigureProject(TestScenePaths);


            var outputFilePrefix = CommandLineBuilder.GetOutputFilePrefix();
            var apkPath          = outputFilePrefix + ".apk";
            var aabPath          = outputFilePrefix + ".aab";

            var buildPlayerOptions = PlayInstantBuilder.CreateBuildPlayerOptions(apkPath, BuildOptions.None);

            if (!PlayInstantBuilder.BuildAndSign(buildPlayerOptions))
            {
                throw new Exception("APK build failed");
            }

            DownloadBundletoolIfNecessary();
            if (!AppBundlePublisher.Build(aabPath))
            {
                throw new Exception("AAB build failed");
            }
        }
예제 #3
0
 /// <summary>
 /// Builds an Android App Bundle using the specified build options.
 ///
 /// Before calling this method use PlayInstantBuildSettings.SetInstantBuildType() to decide whether to build an
 /// instant app bundle or a regular app bundle for installed apps.
 ///
 /// If this method is invoked in Batch Mode, for example from a command line build, then the entire build will
 /// run on the main thread. In this case the <see cref="forceSynchronousBuild"/> parameter has no effect.
 ///
 /// If this method is invoked by a script running from an interactive Editor UI, some of the build will run on
 /// a background thread and this method will return before the full build is complete. This behavior can be
 /// overridden by setting the <see cref="forceSynchronousBuild"/> parameter to true; in this case the entire
 /// build will run on the main thread. Note that this freezes the Editor UI.
 ///
 /// The asynchronous BuildBundle() method method should be preferred when building on Unity 2018.4 or higher.
 /// </summary>
 /// <param name="buildPlayerOptions">A Unity BuildPlayerOptions including the output file path.</param>
 /// <param name="assetPackConfig">The asset packs to include in the Android App Bundle, if any.</param>
 /// <param name="forceSynchronousBuild">If true, the build should only run on the main thread.</param>
 /// <returns>
 /// True if the build succeeded or began running in the background, false if it failed or was cancelled.
 /// </returns>
 public static bool BuildBundle(
     BuildPlayerOptions buildPlayerOptions,
     AssetPackConfig assetPackConfig = null,
     bool forceSynchronousBuild      = false)
 {
     return(AppBundlePublisher.Build(buildPlayerOptions, assetPackConfig, forceSynchronousBuild));
 }
예제 #4
0
 public static bool BuildBundleWithAssetPacks(BuildPlayerOptions buildPlayerOptions, TextureCompressionFormat textureCompressionFormat, string buildPath)
 {
     if (buildPlayerOptions.target != BuildTarget.Android)
     {
         return(false);
     }
     return(AppBundlePublisher.Build(buildPlayerOptions, CreateAssetPacks(textureCompressionFormat, buildPath)));
 }
예제 #5
0
 /// <summary>
 /// Builds an Android App Bundle using the specified build options. Before calling this method use
 /// PlayInstantBuildSettings.SetInstantBuildType() to decide whether to build an instant app bundle or a
 /// regular app bundle for installed apps.
 /// </summary>
 /// <param name="buildPlayerOptions">A Unity BuildPlayerOptions including the output file path.</param>
 /// <param name="assetPackConfig">The asset packs to include in the Android App Bundle, if any.</param>
 /// <returns>True if the build succeeded, false if it failed or was cancelled.</returns>
 public static bool BuildBundle(BuildPlayerOptions buildPlayerOptions, AssetPackConfig assetPackConfig = null)
 {
     return(AppBundlePublisher.Build(buildPlayerOptions, assetPackConfig ?? new AssetPackConfig()));
 }