3

Does anyone know how I can enable the App Bundle (Google Play) option when building with the Unity BuildPipeline? Trying to get this to work with our CI server, this is the code currently used to create an APK:

BuildPlayerOptions prodBuildPlayerOptions = new BuildPlayerOptions();
 prodBuildPlayerOptions.scenes = scenes;
 prodBuildPlayerOptions.locationPathName = $"PSS.Prod.{baseBuildFileName}.apk";
 prodBuildPlayerOptions.target = BuildTarget.Android;
 prodBuildPlayerOptions.options = BuildOptions.None;
 BuildPipeline.BuildPlayer(prodBuildPlayerOptions);

Any help would be greatly appreciated! Cheers, Thomas

Thomas Maw
  • 405
  • 4
  • 10

2 Answers2

4

According to the document, just do:

EditorUserBuildSettings.buildAppBundle = true;

If Unity version is lower than 2018, also need to set:

EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
shingo
  • 18,436
  • 5
  • 23
  • 42
0

I am using this code in old version Unity(2017.4.1f1), and I think you can find AppBundle option in 'EditorUserBuildSetting' like this:

EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Gradle;
EditorUserBuildSettings.exportAsGoogleAndroidProject = true;
Di Zhang
  • 336
  • 2
  • 7
  • In my case I'm trying to build to a Google Play App Bundle (.aab) not to a project. I've posted the answer which solved my problem :) – Thomas Maw May 28 '19 at 11:35