Conversation
Automatically update Assets/Plugins/Android/OneSignalConfig.androidlib/build.gradle with the contains provided by the OneSignal SDK. This way the app developer doesn't have to take any manual steps when upgrading to Unity 6. The changes to build.gradle were done in commit d253d42
Also update example project with missing build.gradle namespace.
| [InitializeOnLoad] | ||
| sealed class MigrateAndroidResources { | ||
| static MigrateAndroidResources() { | ||
| UpdateBuildDotGradleContains(); |
There was a problem hiding this comment.
I am not familiar with our Unity SDK process, is my understanding below correct?
-
I don’t see where this new class is being called, so this class is automatically initialized due to
InitializeOnLoad? -
The main logic effectively takes the contents that is in
com.onesignal.unity.android/Editor/OneSignalConfig.androidlib/build.gradleand replaces the contents in the fileOneSignalExample/Assets/Plugins/Android/OneSignalConfig.androidlib/build.gradle, for example, if they are different. This is because the fileOneSignalExample/Assets/Plugins/Android/OneSignalConfig.androidlib/build.gradleis automatically generated and consumers wouldn’t manipulate this file themselves, but this file may not automatically update whencom.onesignal.unity.android/Editor/OneSignalConfig.androidlib/build.gradlechanges. Hence, why we need to do this migration step to save the client a hassle and questions?
There was a problem hiding this comment.
- Yes, the
[InitializeOnLoad]means Unity will call the static constructor in a few scenarios; A. the SDK is added; B. The SDK is updated; - Correct
Description
One Line Summary
Automatically apply required changes for Unity 6 build compatibility, this only effects Android.
Details
Follow up to PR #776
Motivation
If changes were not applied automatic it will lead extra work the app developer has to search for or may reach out to OneSignal support for help.
Scope
Only effects Android builds.
Testing
Unit testing
None
Manual testing
Tested with Unity 6000.0.42f1.7976.8784 on macOS.
Made changes to the file located at
Assets/Plugins/Android/OneSignalConfig.androidlib/build.gradleand ensured it reverts it.Affected code checklist
Checklist
Overview
Testing
Final pass
This change is