Skip to content

Commit 76a3f36

Browse files
committed
attempt to resolve before a build
Due to changes in newer versions of Unity, plugin modules are not reloaded before build and this meant that some of our optimizations to resolve only when necessary didn't work as expected. With this fix, we will be running a resolve every build (provided there were no build errors in prior attempts), and also run it only on one scene for a build with multiple scenes. Jetifier enabling via gradle properties wasn't flagged as a build setting that is checked for differences during "are there differences for a new resolve?". Bug: 170395178 Fixes: #810 Change-Id: I2b8994497bf48c2eb6276137289927859e10f64f
1 parent 62d8332 commit 76a3f36

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

source/AndroidResolver/src/PlayServicesResolver.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,18 @@ private static void OnPostprocessAllAssets(string[] importedAssets,
11521152
/// </summary>
11531153
private static int scenesProcessed = 0;
11541154

1155+
/// <summary>
1156+
/// Reset static variable after every successful build.
1157+
/// </summary>
1158+
[UnityEditor.Callbacks.PostProcessBuildAttribute(0)]
1159+
private static void OnPostProcessBuild(UnityEditor.BuildTarget target, string path) {
1160+
// Since certain versions of Unity do not reload the module, we want
1161+
// to reset this variable in order to allow an attempt to resolve in OnPostProcessScene().
1162+
// Caveat: Unity calls this only after a successful build. We should really be calling
1163+
// this after every build (successful or not).
1164+
scenesProcessed = 0;
1165+
}
1166+
11551167
/// <summary>
11561168
/// If auto-resolution is enabled, run resolution synchronously before building the
11571169
/// application.
@@ -1171,6 +1183,8 @@ private static void OnPostProcessScene() {
11711183
if (scenesProcessed > 1) return;
11721184
Log("Starting auto-resolution before scene build...", level: LogLevel.Verbose);
11731185
bool success = ResolveSync(false, true);
1186+
// If resolve fails, we want to try the resolve next time around.
1187+
if(!success) scenesProcessed--;
11741188
Log(String.Format("Android resolution {0}.", success ? "succeeded" : "failed"),
11751189
level: LogLevel.Verbose);
11761190
}
@@ -2475,6 +2489,7 @@ internal static Dictionary<string, string> GetResolutionSettings() {
24752489
{"bundleId", GetAndroidApplicationId()},
24762490
{"gradleBuildEnabled", buildSystemSettings.GradleBuildEnabled.ToString()},
24772491
{"gradleTemplateEnabled", buildSystemSettings.GradleTemplateEnabled.ToString()},
2492+
{"gradlePropertiesTemplateEnabled", buildSystemSettings.GradlePropertiesTemplateEnabled.ToString()},
24782493
{"projectExportEnabled", buildSystemSettings.ProjectExportEnabled.ToString()},
24792494
{"androidAbis", androidAbis.ToString()},
24802495
};

0 commit comments

Comments
 (0)