File tree Expand file tree Collapse file tree 4 files changed +58
-7
lines changed
OneSignalExample/Assets/Plugins/Android/OneSignalConfig.androidlib
com.onesignal.unity.android/Editor
OneSignalConfig.androidlib Expand file tree Collapse file tree 4 files changed +58
-7
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ WARNING: Do NOT Modify! Changes will be overwritten by the OneSignal plugin.
3+ */
4+
15apply plugin : ' com.android.library'
26
37android {
8+ namespace ' com.onesignal.onesignalsdk'
9+
410 sourceSets {
511 main {
612 manifest. srcFile ' AndroidManifest.xml'
@@ -9,16 +15,16 @@ android {
915
1016 def unityLib = project(' :unityLibrary' ). extensions. getByName(' android' )
1117
12- defaultConfig {
18+ defaultConfig {
1319 consumerProguardFiles " consumer-proguard.pro"
1420 minSdkVersion unityLib. defaultConfig. minSdkVersion. mApiLevel
1521 targetSdkVersion unityLib. defaultConfig. targetSdkVersion. mApiLevel
16- }
22+ }
1723
1824 compileSdkVersion unityLib. compileSdkVersion
1925 buildToolsVersion unityLib. buildToolsVersion
2026
2127 lintOptions {
2228 abortOnError false
2329 }
24- }
30+ }
Original file line number Diff line number Diff line change 1+ using System . IO ;
2+ using UnityEditor ;
3+
4+ namespace OneSignalSDK {
5+
6+ [ InitializeOnLoad ]
7+ sealed class MigrateAndroidResources {
8+ static MigrateAndroidResources ( ) {
9+ UpdateBuildDotGradleContains ( ) ;
10+ }
11+
12+ /// <summary>
13+ /// Updates Assets/Plugins/Android/OneSignalConfig.androidlib/build.gradle
14+ /// with contains provided by OneSignal-Unity-SDK 5.1.13.
15+ /// Includes compatibility with Unity 6, as it's Gradle version has new
16+ /// requirements.
17+ /// </summary>
18+ private static void UpdateBuildDotGradleContains ( ) {
19+ if ( ! Directory . Exists ( ExportAndroidResourcesStep . _pluginExportPath ) )
20+ return ;
21+
22+ string exportedFilename = Path . Combine (
23+ ExportAndroidResourcesStep . _pluginExportPath ,
24+ "build.gradle"
25+ ) ;
26+ string exportedContains = File . ReadAllText ( exportedFilename ) ;
27+
28+ string packageFilename = Path . Combine (
29+ ExportAndroidResourcesStep . _pluginPackagePath ,
30+ "build.gradle"
31+ ) ;
32+ string packageContains = File . ReadAllText ( packageFilename ) ;
33+
34+ // We want to copy only when needed, otherwise it can reset file
35+ // properties, such as permissions and timestamps
36+ if ( exportedContains != packageContains ) {
37+ File . Copy ( packageFilename , exportedFilename , true ) ;
38+ }
39+ }
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ /*
2+ WARNING: Do NOT Modify! Changes will be overwritten by the OneSignal plugin.
3+ */
4+
15apply plugin : ' com.android.library'
26
37android {
@@ -11,11 +15,11 @@ android {
1115
1216 def unityLib = project(' :unityLibrary' ). extensions. getByName(' android' )
1317
14- defaultConfig {
18+ defaultConfig {
1519 consumerProguardFiles " consumer-proguard.pro"
1620 minSdkVersion unityLib. defaultConfig. minSdkVersion. mApiLevel
1721 targetSdkVersion unityLib. defaultConfig. targetSdkVersion. mApiLevel
18- }
22+ }
1923
2024 compileSdkVersion unityLib. compileSdkVersion
2125 buildToolsVersion unityLib. buildToolsVersion
Original file line number Diff line number Diff line change @@ -131,8 +131,8 @@ private void MigratePluginToAndroidlib() {
131131 private static readonly string _packagePath = Path . Combine ( "Packages" , "com.onesignal.unity.android" , "Editor" ) ;
132132 private static readonly string _androidPluginsPath = Path . Combine ( "Assets" , "Plugins" , "Android" ) ;
133133
134- private static readonly string _pluginPackagePath = Path . Combine ( _packagePath , _pluginName ) ;
135- private static readonly string _pluginExportPath = Path . Combine ( _androidPluginsPath , _pluginName ) ;
134+ internal static readonly string _pluginPackagePath = Path . Combine ( _packagePath , _pluginName ) ;
135+ internal static readonly string _pluginExportPath = Path . Combine ( _androidPluginsPath , _pluginName ) ;
136136
137137 private static readonly string _manifestPackagePath = Path . Combine ( _pluginPackagePath , "AndroidManifest.xml" ) ;
138138 private static readonly string _manifestExportPath = Path . Combine ( _pluginExportPath , "AndroidManifest.xml" ) ;
You can’t perform that action at this time.
0 commit comments