Skip to content

Commit 0f0ef22

Browse files
Mobile Ads Developer Relationscopybara-github
authored andcommitted
OpenUPM release CL for version 10.4.2.
PiperOrigin-RevId: 799195972
1 parent 9090c5c commit 0f0ef22

File tree

88 files changed

+146
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+146
-134
lines changed

packages/com.google.ads.mobile/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
Google Mobile Ads Unity Plugin Change Log
22

3+
**************
4+
Version 10.4.2
5+
**************
6+
7+
- Fix issue with macros in `BuildPreProcessor` for Unity Editor 2021.
8+
- Added `androidx.lifecycle` dependency required for AppOpenAd.
9+
10+
Built and tested with:
11+
12+
- Google Mobile Ads Android SDK 24.5.0.
13+
- Google Mobile Ads iOS SDK 12.9.0.
14+
- Google User Messaging Platform Android SDK 3.2.0
15+
- Google User Messaging Platform iOS SDK 3.0.0
16+
- External Dependency Manager for Unity 1.2.186
17+
318
**************
419
Version 10.4.1
520
**************

packages/com.google.ads.mobile/CHANGELOG.md.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/com.google.ads.mobile/GoogleMobileAds/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
Google Mobile Ads Unity Plugin Change Log
22

3+
**************
4+
Version 10.4.2
5+
**************
6+
7+
- Fix issue with macros in `BuildPreProcessor` for Unity Editor 2021.
8+
- Added `androidx.lifecycle` dependency required for AppOpenAd.
9+
10+
Built and tested with:
11+
12+
- Google Mobile Ads Android SDK 24.5.0.
13+
- Google Mobile Ads iOS SDK 12.9.0.
14+
- Google User Messaging Platform Android SDK 3.2.0
15+
- Google User Messaging Platform iOS SDK 3.0.0
16+
- External Dependency Manager for Unity 1.2.186
17+
318
**************
419
Version 10.4.1
520
**************

packages/com.google.ads.mobile/GoogleMobileAds/CHANGELOG.md.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/com.google.ads.mobile/GoogleMobileAds/Editor/BuildPreProcessor.cs

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#if UNITY_ANDROID
2-
#if UNITY_2022 || UNITY_2021_3_5 ||UNITY_2021_3_49 || UNITY_2021_3_48 || UNITY_2021_3_47 || UNITY_2021_3_46 || UNITY_2021_3_45 || UNITY_2021_3_44 || UNITY_2021_3_43 || UNITY_2021_3_42 || UNITY_2021_3_41
2+
#if UNITY_2022 || UNITY_2021_3_55 || UNITY_2021_3_54 || UNITY_2021_3_53 || UNITY_2021_3_52 || UNITY_2021_3_51 || UNITY_2021_3_50 || UNITY_2021_3_49 || UNITY_2021_3_48 || UNITY_2021_3_47 || UNITY_2021_3_46 || UNITY_2021_3_45 || UNITY_2021_3_44 || UNITY_2021_3_43 || UNITY_2021_3_42 || UNITY_2021_3_41
33
// 2021.3.41f1+ Gradle version 7.5.1+
44
// https://docs.unity3d.com/2021.3/Documentation/Manual/android-gradle-overview.html
55
#define ANDROID_GRADLE_BUILD_JETIFIER_ENTRY_ENABLED
66
#endif
77

88
#if UNITY_6000_0_OR_NEWER || UNITY_2023 || ANDROID_GRADLE_BUILD_JETIFIER_ENTRY_ENABLED
9-
#define ANDROID_GRADLE_BUILD_POST_PROCESSOR_ENABLED
9+
#define ANDROID_GRADLE_BUILD_PRE_PROCESSOR_ENABLED
1010
#endif
1111

1212
using System;
@@ -24,8 +24,8 @@ namespace GoogleMobileAds.Editor
2424
/// with the Google Mobile Ads SDK. This includes:
2525
/// - Verify the Android Google Mobile Ads app ID is set.
2626
/// - Throw an exception if the Android Google Mobile Ads app ID is not set.
27-
/// - Set minimum API level to 23.
28-
/// - Set target API level to 34.
27+
/// - Set minimum API level to 23 (the target API level may be automatically set, we should not
28+
/// hardcode it).
2929
/// - Enable Custom Main Gradle Template.
3030
/// - Update Custom Main Gradle Template with dependencies using the Play Services Resolver.
3131
/// - Enable Custom Gradle Properties Template.
@@ -34,7 +34,6 @@ namespace GoogleMobileAds.Editor
3434
public class BuildPreProcessor : IPreprocessBuildWithReport
3535
{
3636
const int MinimumAPILevel = 23;
37-
const int TargetAPILevel = 34;
3837
const string CustomGradlePropertiesTemplatesFileName = "gradleTemplate.properties";
3938
const string CustomMainGradleTemplateFileName = "mainTemplate.gradle";
4039
const string JetifierEntry =
@@ -46,29 +45,19 @@ public class BuildPreProcessor : IPreprocessBuildWithReport
4645

4746
public void OnPreprocessBuild(BuildReport report)
4847
{
49-
if (GoogleMobileAdsSettings.LoadInstance().GoogleMobileAdsAndroidAppId.Length == 0)
50-
{
51-
throw new BuildFailedException(
52-
"The Android Google Mobile Ads app ID is empty. "+
53-
"Add a valid app ID to your GoogleMobileAdsSettings to run ads properly.");
54-
}
55-
if(!GoogleMobileAdsSettings.LoadInstance().EnableGradleBuildPostProcessor)
48+
if(!GoogleMobileAdsSettings.LoadInstance().EnableGradleBuildPreProcessor)
5649
{
5750
return;
5851
}
59-
#if ANDROID_GRADLE_BUILD_POST_PROCESSOR_ENABLED
52+
// For more details see, https://developers.google.com/admob/unity/android
53+
#if ANDROID_GRADLE_BUILD_PRE_PROCESSOR_ENABLED
6054
ApplyBuildSettings(report);
61-
#else
62-
throw new BuildFailedException(
63-
"Unity Editor 2021.3.41f1 or higher is required to enable the gradle build " +
64-
"post-processor. Update your build settings manually or disable the gradle build "+
65-
"post-processor. For more details see, https://developers.google.com/admob/unity/android");
66-
#endif
55+
#endif
6756
}
6857

6958
private void ApplyBuildSettings(BuildReport report)
7059
{
71-
Debug.Log("Running Android Gradle Build Post-Processor.");
60+
Debug.Log("Running Android Gradle Build Pre-Processor.");
7261

7362
// Set Minimum Api Level.
7463
if (PlayerSettings.Android.minSdkVersion < (AndroidSdkVersions)MinimumAPILevel)
@@ -81,28 +70,17 @@ private void ApplyBuildSettings(BuildReport report)
8170
Debug.Log($"Verified Minimum API Level is >= {MinimumAPILevel}.");
8271
}
8372

84-
// Set Target Api Level.
85-
if (PlayerSettings.Android.targetSdkVersion < (AndroidSdkVersions)TargetAPILevel)
86-
{
87-
PlayerSettings.Android.targetSdkVersion = (AndroidSdkVersions)TargetAPILevel;
88-
Debug.Log($"Set target API Level to: {TargetAPILevel}");
89-
}
90-
else
91-
{
92-
Debug.Log($"Verified Target API Level is >= {TargetAPILevel}.");
93-
}
94-
9573
// Create Assets/Plugins folder.
96-
if (!AssetDatabase.IsValidFolder("Assets/Plugins"))
74+
if (!AssetDatabase.IsValidFolder(Path.Combine("Assets", "Plugins")))
9775
{
9876
AssetDatabase.CreateFolder("Assets", "Plugins");
9977
AssetDatabase.Refresh();
10078
}
10179

10280
// Create Assets/Plugins/Android folder.
103-
if (!AssetDatabase.IsValidFolder("Assets/Plugins/Android"))
81+
if (!AssetDatabase.IsValidFolder(Path.Combine("Assets", "Plugins", "Android")))
10482
{
105-
AssetDatabase.CreateFolder("Assets/Plugins", "Android");
83+
AssetDatabase.CreateFolder(Path.Combine("Assets", "Plugins"), "Android");
10684
AssetDatabase.Refresh();
10785
}
10886

@@ -115,7 +93,7 @@ private void ApplyBuildSettings(BuildReport report)
11593
#if ANDROID_GRADLE_BUILD_JETIFIER_ENTRY_ENABLED
11694
string customGradlePropertiesTemplatesFilePath = Path.Combine(
11795
Application.dataPath,
118-
"Plugins/Android",
96+
"Plugins", "Android",
11997
CustomGradlePropertiesTemplatesFileName);
12098
if (File.Exists(customGradlePropertiesTemplatesFilePath))
12199
{
@@ -141,7 +119,7 @@ private void ApplyBuildSettings(BuildReport report)
141119

142120
Debug.Log("Resolving Android Gradle dependencies.");
143121
PlayServicesResolver.ResolveSync(true);
144-
Debug.Log("Android Build Post-Processor finished.");
122+
Debug.Log("Android Build Pre-Processor finished.");
145123
}
146124

147125
/// <summary>
@@ -154,16 +132,15 @@ private void EnsureGradleFileExists(string fileName)
154132
bool foundDisabledFile = false;
155133

156134
// Check for target file.
157-
string targetPath = Path.Combine(Application.dataPath,
158-
$"Plugins/Android/{fileName}");
135+
string targetPath = Path.Combine(Application.dataPath, "Plugins", "Android", fileName);
159136
if (File.Exists(targetPath))
160137
{
161138
foundTargetFile = true;
162139
}
163140

164141
// Check for the ".DISABLED" file.
165-
string disabledPath = Path.Combine(Application.dataPath,
166-
$"Plugins/Android/{fileName}.DISABLED");
142+
string disabledPath = Path.Combine(Application.dataPath, "Plugins", "Android",
143+
$"{fileName}.DISABLED");
167144
if (File.Exists(disabledPath))
168145
{
169146
foundDisabledFile = true;
@@ -200,7 +177,7 @@ private void EnsureGradleFileExists(string fileName)
200177
if (!File.Exists(sourceFileName))
201178
{
202179
throw new BuildFailedException(
203-
"Android Build Post-Processor failed. "+
180+
"Android Build Pre-Processor failed. "+
204181
$"Unable to find source {sourceFileName}. Is your file system read-only?" +
205182
"If this issue persists, contact Google Mobile Ads Support "+
206183
"at https://developers.google.com/admob/support");

packages/com.google.ads.mobile/GoogleMobileAds/Editor/BuildPreProcessor.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/com.google.ads.mobile/GoogleMobileAds/Editor/EditorLocalization.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/com.google.ads.mobile/GoogleMobileAds/Editor/EditorLocalizationData.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/com.google.ads.mobile/GoogleMobileAds/Editor/EditorPathUtils.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/com.google.ads.mobile/GoogleMobileAds/Editor/GoogleMobileAds.Editor.asmdef.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)