Skip to content

Commit 2f63e53

Browse files
committed
Add check for min SDK when building
1 parent e6ad9a5 commit 2f63e53

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

com.unity.mobile.notifications/Editor/AndroidNotificationPostProcessor.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ public class AndroidNotificationPostProcessor : IPostGenerateGradleAndroidProjec
1515

1616
public void OnPostGenerateGradleAndroidProject(string projectPath)
1717
{
18+
MinSdkCheck();
19+
1820
CopyNotificationResources(projectPath);
1921

2022
InjectAndroidManifest(projectPath);
2123
}
2224

25+
private void MinSdkCheck()
26+
{
27+
#if !UNITY_2020_2_OR_NEWER
28+
// API level 21 not supported since 2020.2, need to check for prior releases
29+
const AndroidSdkVersions kMinAndroidSdk = AndroidSdkVersions.AndroidApiLevel21;
30+
31+
if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel21)
32+
throw new NotSupportedException(string.Format("Minimum Android API level supported by notifications package is {0}, your Player Settings have it set to {1}",
33+
(int)kMinAndroidSdk, PlayerSettings.Android.minSdkVersion));
34+
#endif
35+
}
36+
2337
private void CopyNotificationResources(string projectPath)
2438
{
2539
// The projectPath points to the the parent folder instead of the actual project path.

0 commit comments

Comments
 (0)