Skip to content

Commit 53497e2

Browse files
author
game-workstore-bot
committed
Package Update 1.5.0
1 parent 2f06287 commit 53497e2

31 files changed

+957
-679
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog for com.google.android.appbundle
22

3+
## [1.5.0] - 2021-06-14
4+
### New Features
5+
- Added a new Bundletool method for building AABs (requires 2018.4+ and .NET 4+)
6+
- Added API and UI options to replace OBB files with an install-time asset pack
7+
- Added API options for customizing file compression within generated APKs
8+
- Changes to support minSdkVersion of 22 in Unity 2021.2
9+
- Updated bundletool-all.jar from 1.5.0 to 1.6.1
10+
### Bug Fixes
11+
- Fixed issue #80: prevent building on Unity 2020.2 and early versions of 2020.3 and 2021.1
12+
- Fixed issue #106: bundletool build-bundle crashed when output file was specified without a parent directory
13+
### Other
14+
- Removed ability to compile plugin with Unity 5.6, 2017.1, 2017.2, 2017.3, 2018.1, and 2018.2
15+
- Require Gradle for all Unity builds
16+
- Update minimum Target SDK version to 29
17+
318
## [1.4.0] - 2021-03-08
419
### New Features
520
- Updated bundletool-all.jar from 1.2.0 to 1.5.0

Editor/Scripts/AndroidAppBundle.cs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// In the Unity 2017 series the EditorUserBuildSettings.buildAppBundle field was introduced in 2017.4.17.
16-
// It might seem preferable to modify buildAppBundle using reflection, but the field is extern.
17-
// Instead check for quite a few versions in the 2017.4.17+ series.
18-
// NOTE: this supports up to UNITY_2017_4_50 and will have to be extended if additional versions are released.
19-
20-
#if UNITY_2018_3_OR_NEWER || UNITY_2017_4_17 || UNITY_2017_4_18 || UNITY_2017_4_19 || UNITY_2017_4_20 || UNITY_2017_4_21 || UNITY_2017_4_22 || UNITY_2017_4_23 || UNITY_2017_4_24 || UNITY_2017_4_25 || UNITY_2017_4_26 || UNITY_2017_4_27 || UNITY_2017_4_28 || UNITY_2017_4_29 || UNITY_2017_4_30 || UNITY_2017_4_31 || UNITY_2017_4_32 || UNITY_2017_4_33 || UNITY_2017_4_34 || UNITY_2017_4_35 || UNITY_2017_4_36 || UNITY_2017_4_37 || UNITY_2017_4_38 || UNITY_2017_4_39 || UNITY_2017_4_40 || UNITY_2017_4_41 || UNITY_2017_4_42 || UNITY_2017_4_43 || UNITY_2017_4_44 || UNITY_2017_4_45 || UNITY_2017_4_46 || UNITY_2017_4_47 || UNITY_2017_4_48 || UNITY_2017_4_49 || UNITY_2017_4_50
21-
#define GOOGLE_ANDROID_APP_BUNDLE_HAS_NATIVE_SUPPORT
22-
using UnityEditor;
23-
#endif
2415
using System;
2516
using System.Text.RegularExpressions;
2617
using Google.Android.AppBundle.Editor.Internal.Utils;
18+
using UnityEditor;
2719

2820
namespace Google.Android.AppBundle.Editor
2921
{
@@ -34,10 +26,15 @@ namespace Google.Android.AppBundle.Editor
3426
public static class AndroidAppBundle
3527
{
3628
/// <summary>
37-
/// The base module contains the Unity game engine.
29+
/// Reserved name for the base module that contains the Unity game engine.
3830
/// </summary>
3931
public const string BaseModuleName = "base";
4032

33+
/// <summary>
34+
/// Reserved name for the module that separates the base module's assets into an install-time asset pack.
35+
/// </summary>
36+
public const string BaseAssetsModuleName = "base_assets";
37+
4138
/// <summary>
4239
/// Regex used to determine whether a module name is valid.
4340
/// See https://github.com/google/bundletool/blob/master/src/main/java/com/android/tools/build/bundletool/model/BundleModuleName.java#L38
@@ -46,59 +43,61 @@ public static class AndroidAppBundle
4643

4744
/// <summary>
4845
/// Returns true if the specified name is a valid Android App Bundle module name, false otherwise.
49-
/// The name "base" is reserved for the base module, so also return false in that case.
46+
/// Certain names like "base" are reserved, so also return false in those cases.
5047
/// </summary>
5148
public static bool IsValidModuleName(string name)
5249
{
5350
// TODO(b/131241163): enforce a name length limit if we make it much smaller than 65535.
5451
return name != null
5552
&& NameRegex.IsMatch(name)
56-
&& !name.Equals(BaseModuleName, StringComparison.OrdinalIgnoreCase);
53+
&& CheckReservedName(name, BaseModuleName)
54+
&& CheckReservedName(name, BaseAssetsModuleName);
5755
}
5856

5957
/// <summary>
60-
/// Returns true if this version of the Unity Editor has native support for building an Android App Bundle,
61-
/// and false otherwise.
58+
/// Always returns true. Previously indicated if this version of the Unity Editor has native support for
59+
/// building an Android App Bundle.
6260
/// </summary>
61+
// TODO(b/189958664): Needed for 1.x API compatibility. Should be removed with 2.x.
62+
[Obsolete("This is always true")]
6363
public static bool HasNativeBuildSupport()
6464
{
65-
#if GOOGLE_ANDROID_APP_BUNDLE_HAS_NATIVE_SUPPORT
6665
return true;
67-
#else
68-
return false;
69-
#endif
7066
}
7167

7268
/// <summary>
7369
/// Returns EditorUserBuildSettings.buildAppBundle if it is defined and false otherwise.
7470
/// </summary>
71+
// TODO(b/189958664): Needed for 1.x API compatibility. Should be removed with 2.x.
72+
[Obsolete("Use EditorUserBuildSettings.buildAppBundle directly instead")]
7573
public static bool IsNativeBuildEnabled()
7674
{
77-
#if GOOGLE_ANDROID_APP_BUNDLE_HAS_NATIVE_SUPPORT
7875
return EditorUserBuildSettings.buildAppBundle;
79-
#else
80-
return false;
81-
#endif
8276
}
8377

8478
/// <summary>
8579
/// Enable the EditorUserBuildSettings.buildAppBundle field if it is defined.
8680
/// </summary>
81+
// TODO(b/189958664): Needed for 1.x API compatibility. Should be removed with 2.x.
82+
[Obsolete("Use EditorUserBuildSettings.buildAppBundle directly instead")]
8783
public static void EnableNativeBuild()
8884
{
89-
#if GOOGLE_ANDROID_APP_BUNDLE_HAS_NATIVE_SUPPORT
9085
EditorUserBuildSettings.buildAppBundle = true;
91-
#endif
9286
}
9387

9488
/// <summary>
9589
/// Disable the EditorUserBuildSettings.buildAppBundle field if it is defined.
9690
/// </summary>
91+
// TODO(b/189958664): Needed for 1.x API compatibility. Should be removed with 2.x.
92+
[Obsolete("Use EditorUserBuildSettings.buildAppBundle directly instead")]
9793
public static void DisableNativeBuild()
9894
{
99-
#if GOOGLE_ANDROID_APP_BUNDLE_HAS_NATIVE_SUPPORT
10095
EditorUserBuildSettings.buildAppBundle = false;
101-
#endif
96+
}
97+
98+
private static bool CheckReservedName(string name, string reserved)
99+
{
100+
return !name.Equals(reserved, StringComparison.OrdinalIgnoreCase);
102101
}
103102
}
104-
}
103+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#if UNITY_2018_4_OR_NEWER && !NET_LEGACY
16+
using System;
17+
18+
namespace Google.Android.AppBundle.Editor
19+
{
20+
/// <summary>
21+
/// Exception thrown in case of certain Android build failures.
22+
/// </summary>
23+
public class AndroidBuildException : Exception
24+
{
25+
internal AndroidBuildException(string errorMessage, AndroidBuildReport androidBuildReport) : base(errorMessage)
26+
{
27+
AndroidBuildReport = androidBuildReport;
28+
}
29+
30+
internal AndroidBuildException(Exception exception, AndroidBuildReport androidBuildReport)
31+
: base(exception.Message, exception)
32+
{
33+
AndroidBuildReport = androidBuildReport;
34+
}
35+
36+
/// <summary>
37+
/// An <see cref="AndroidBuildReport"/> associated with this build failure. Note that the build may fail
38+
/// after the Android Player is built but before the AAB is ready; in this case the BuildReport will
39+
/// likely indicate a BuildResult of Succeeded since it's reporting the result of calling BuildPlayer().
40+
/// </summary>
41+
public AndroidBuildReport AndroidBuildReport { get; }
42+
}
43+
}
44+
#endif

Editor/Scripts/AndroidBuildException.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using System;
16+
using UnityEditor;
17+
18+
namespace Google.Android.AppBundle.Editor
19+
{
20+
/// <summary>
21+
/// Options that configure the behavior of an Android build.
22+
/// </summary>
23+
public class AndroidBuildOptions
24+
{
25+
/// <summary>
26+
/// Constructor.
27+
/// </summary>
28+
/// <param name="buildPlayerOptions">BuildPlayerOptions required for any build.</param>
29+
/// <exception cref="ArgumentException">Thrown if the BuildPlayerOptions build target isn't Android.</exception>
30+
public AndroidBuildOptions(BuildPlayerOptions buildPlayerOptions)
31+
{
32+
if (buildPlayerOptions.target != BuildTarget.Android)
33+
{
34+
throw new ArgumentException("Unexpected non-Android BuildTarget: " + buildPlayerOptions.target);
35+
}
36+
37+
if (buildPlayerOptions.targetGroup != BuildTargetGroup.Android)
38+
{
39+
throw new ArgumentException(
40+
"Unexpected non-Android BuildTargetGroup: " + buildPlayerOptions.targetGroup);
41+
}
42+
43+
BuildPlayerOptions = buildPlayerOptions;
44+
CompressionOptions = new CompressionOptions();
45+
}
46+
47+
/// <summary>
48+
/// The build options passed to BuildPipeline.BuildPlayer(), including scenes and output location.
49+
/// </summary>
50+
public BuildPlayerOptions BuildPlayerOptions { get; private set; }
51+
52+
/// <summary>
53+
/// Returns the AssetPackConfig to use for the build, or null.
54+
/// </summary>
55+
public AssetPackConfig AssetPackConfig { get; set; }
56+
57+
/// <summary>
58+
/// Options for overriding the default file compression strategy.
59+
/// </summary>
60+
public CompressionOptions CompressionOptions { get; set; }
61+
62+
/// <summary>
63+
/// If true, forces the entire build to run on the main thread, potentially freezing the Editor UI during some
64+
/// build steps. This setting doesn't affect batch mode builds, which always run on the main thread.
65+
/// </summary>
66+
public bool ForceSingleThreadedBuild { get; set; }
67+
}
68+
}

Editor/Scripts/AndroidBuildOptions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#if UNITY_2018_4_OR_NEWER && !NET_LEGACY
16+
using UnityEditor.Build.Reporting;
17+
18+
namespace Google.Android.AppBundle.Editor
19+
{
20+
// Note: this class exists (versus using BuildReport directly) so that additional build info can be added later.
21+
/// <summary>
22+
/// Report containing the results of an Android build.
23+
/// </summary>
24+
public class AndroidBuildReport
25+
{
26+
/// <summary>
27+
/// Constructor.
28+
/// </summary>
29+
/// <param name="buildReport">A BuildPlayer() BuildReport.</param>
30+
internal AndroidBuildReport(BuildReport buildReport)
31+
{
32+
Report = buildReport;
33+
}
34+
35+
/// <summary>
36+
/// The <see cref="BuildReport"/> generated during the creation of the Android Player. Note that since
37+
/// additional processing occurs after the Player is built, some information in this report may not be useful.
38+
/// For example, the BuildSummary.outputPath will contain an intermediate output file path, not the final
39+
/// AAB output file path.
40+
/// </summary>
41+
public BuildReport Report { get; }
42+
}
43+
}
44+
#endif

Editor/Scripts/AndroidBuildReport.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Scripts/AssetPackConfig.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@
2020
namespace Google.Android.AppBundle.Editor
2121
{
2222
/// <summary>
23-
/// Configuration for all asset packs that will be packaged in an Android App Bundle.
23+
/// Configuration for all asset packs that will be packaged in an Android App Bundle (AAB).
2424
/// </summary>
2525
public class AssetPackConfig
2626
{
27+
/// <summary>
28+
/// Indicates that the assets in an AAB's base module should be split into a separate install-time asset
29+
/// pack. Usually when building a game, some assets are stored in the base module's "assets" directory.
30+
/// Games that run into APK size limits may have previously used the "Split Application Binary"
31+
/// option to create APK Expansion (*.obb) files, however this is unsupported with AABs.
32+
/// If Play Console indicates that the base module exceeds a download size limit, for example 150 MB,
33+
/// enabling this option may resolve the issue. See https://developer.android.com/guide/app-bundle.
34+
/// </summary>
35+
public bool SplitBaseModuleAssets;
36+
2737
/// <summary>
2838
/// Dictionary from asset pack name to <see cref="AssetPack"/> object containing info such as delivery mode.
2939
/// Note: asset pack names must start with a letter and can contain only letters, numbers, and underscores.
@@ -34,6 +44,7 @@ public class AssetPackConfig
3444

3545
/// <summary>
3646
/// A dictionary containing the subset of <see cref="AssetPacks"/> that are marked for delivery.
47+
/// Note: the returned Dictionary doesn't indicate whether <see cref="SplitBaseModuleAssets"/> is enabled.
3748
/// </summary>
3849
public Dictionary<string, AssetPack> DeliveredAssetPacks
3950
{
@@ -51,6 +62,15 @@ public Dictionary<string, AssetPack> DeliveredAssetPacks
5162
/// </summary>
5263
public TextureCompressionFormat DefaultTextureCompressionFormat = TextureCompressionFormat.Default;
5364

65+
/// <summary>
66+
/// Returns true if this configuration includes at least 1 asset pack that may be packaged in an AAB.
67+
/// Return true if <see cref="SplitBaseModuleAssets"/> is enabled, even if there are no other asset packs.
68+
/// </summary>
69+
public bool HasDeliveredAssetPacks()
70+
{
71+
return SplitBaseModuleAssets || DeliveredAssetPacks.Any();
72+
}
73+
5474
/// <summary>
5575
/// Package the specified AssetBundle file in its own <see cref="AssetPack"/> with the specified delivery mode.
5676
/// The name of the created asset pack will match that of the specified AssetBundle file.
@@ -192,4 +212,4 @@ private static void CheckAssetPackName(string assetPackName)
192212
}
193213
}
194214
}
195-
}
215+
}

0 commit comments

Comments
 (0)