Skip to content

Commit 658e6d4

Browse files
authored
Merge pull request #168 from adjust/v4201
Version 4.20.1
2 parents cf101ea + 74af4ab commit 658e6d4

File tree

14 files changed

+92
-39
lines changed

14 files changed

+92
-39
lines changed

Assets/Adjust/Android/AdjustAndroid.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace com.adjust.sdk
88
#if UNITY_ANDROID
99
public class AdjustAndroid
1010
{
11-
private const string sdkPrefix = "unity4.20.0";
11+
private const string sdkPrefix = "unity4.20.1";
1212
private static bool launchDeferredDeeplink = true;
1313
private static AndroidJavaClass ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust");
1414
private static AndroidJavaObject ajoCurrentActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity");
-37 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Assets/Adjust/Editor/AdjustEditor.cs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ private static void RunPostBuildScript(BuildTarget target, bool preBuild, string
135135
// - AdSupport.framework
136136
// - iAd.framework
137137

138+
#if UNITY_2019_3_OR_NEWER
139+
string xcodeTarget = xcodeProject.GetUnityFrameworkTargetGuid();
140+
#else
138141
string xcodeTarget = xcodeProject.TargetGuidByName("Unity-iPhone");
142+
#endif
139143

140144
UnityEngine.Debug.Log("[Adjust]: Adding AdSupport.framework to Xcode project.");
141145
xcodeProject.AddFrameworkToProject(xcodeTarget, "AdSupport.framework", true);
@@ -212,25 +216,35 @@ private static void RunPostProcessTasksAndroid()
212216
XmlDocument manifestFile = new XmlDocument();
213217
manifestFile.Load(appManifestPath);
214218

219+
bool manifestHasChanged = false;
220+
215221
// Add needed permissions if they are missing.
216-
AddPermissions(manifestFile);
222+
manifestHasChanged |= AddPermissions(manifestFile);
217223

218224
// Add intent filter to main activity if it is missing.
219-
AddBroadcastReceiver(manifestFile);
225+
manifestHasChanged |= AddBroadcastReceiver(manifestFile);
220226

221-
// Save the changes.
222-
manifestFile.Save(appManifestPath);
227+
if (manifestHasChanged)
228+
{
229+
// Save the changes.
230+
manifestFile.Save(appManifestPath);
223231

224-
// Clean the manifest file.
225-
CleanManifestFile(appManifestPath);
232+
// Clean the manifest file.
233+
CleanManifestFile(appManifestPath);
226234

227-
UnityEngine.Debug.Log("[Adjust]: App's AndroidManifest.xml file check and potential modification completed.");
228-
UnityEngine.Debug.Log("[Adjust]: Please check if any error message was displayed during this process "
229-
+ "and make sure to fix all issues in order to properly use the Adjust SDK in your app.");
235+
UnityEngine.Debug.Log("[Adjust]: App's AndroidManifest.xml file check and potential modification completed.");
236+
UnityEngine.Debug.Log("[Adjust]: Please check if any error message was displayed during this process "
237+
+ "and make sure to fix all issues in order to properly use the Adjust SDK in your app.");
238+
}
239+
else
240+
{
241+
UnityEngine.Debug.Log("[Adjust]: App's AndroidManifest.xml file check completed.");
242+
UnityEngine.Debug.Log("[Adjust]: No modifications performed due to app's AndroidManifest.xml file compatibility.");
243+
}
230244
}
231245
}
232246

233-
private static void AddPermissions(XmlDocument manifest)
247+
private static bool AddPermissions(XmlDocument manifest)
234248
{
235249
// The Adjust SDK needs two permissions to be added to you app's manifest file:
236250
// <uses-permission android:name="android.permission.INTERNET" />
@@ -274,13 +288,16 @@ private static void AddPermissions(XmlDocument manifest)
274288
}
275289
}
276290

291+
bool manifestHasChanged = false;
292+
277293
// If android.permission.INTERNET permission is missing, add it.
278294
if (!hasInternetPermission)
279295
{
280296
XmlElement element = manifest.CreateElement("uses-permission");
281297
element.SetAttribute("android__name", "android.permission.INTERNET");
282298
manifestRoot.AppendChild(element);
283299
UnityEngine.Debug.Log("[Adjust]: android.permission.INTERNET permission successfully added to your app's AndroidManifest.xml file.");
300+
manifestHasChanged = true;
284301
}
285302
else
286303
{
@@ -294,6 +311,7 @@ private static void AddPermissions(XmlDocument manifest)
294311
element.SetAttribute("android__name", "android.permission.ACCESS_WIFI_STATE");
295312
manifestRoot.AppendChild(element);
296313
UnityEngine.Debug.Log("[Adjust]: android.permission.ACCESS_WIFI_STATE permission successfully added to your app's AndroidManifest.xml file.");
314+
manifestHasChanged = true;
297315
}
298316
else
299317
{
@@ -307,6 +325,7 @@ private static void AddPermissions(XmlDocument manifest)
307325
element.SetAttribute("android__name", "android.permission.ACCESS_NETWORK_STATE");
308326
manifestRoot.AppendChild(element);
309327
UnityEngine.Debug.Log("[Adjust]: android.permission.ACCESS_NETWORK_STATE permission successfully added to your app's AndroidManifest.xml file.");
328+
manifestHasChanged = true;
310329
}
311330
else
312331
{
@@ -320,14 +339,17 @@ private static void AddPermissions(XmlDocument manifest)
320339
element.SetAttribute("android__name", "com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE");
321340
manifestRoot.AppendChild(element);
322341
UnityEngine.Debug.Log("[Adjust]: com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE permission successfully added to your app's AndroidManifest.xml file.");
342+
manifestHasChanged = true;
323343
}
324344
else
325345
{
326346
UnityEngine.Debug.Log("[Adjust]: Your app's AndroidManifest.xml file already contains com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE permission.");
327347
}
348+
349+
return manifestHasChanged;
328350
}
329351

330-
private static void AddBroadcastReceiver(XmlDocument manifest)
352+
private static bool AddBroadcastReceiver(XmlDocument manifest)
331353
{
332354
// We're looking for existance of broadcast receiver in the AndroidManifest.xml
333355
// Check out the example below how that usually looks like:
@@ -379,7 +401,7 @@ private static void AddBroadcastReceiver(XmlDocument manifest)
379401
{
380402
UnityEngine.Debug.LogError("[Adjust]: Your app's AndroidManifest.xml file does not contain \"<application>\" node.");
381403
UnityEngine.Debug.LogError("[Adjust]: Unable to add the Adjust broadcast receiver to AndroidManifest.xml.");
382-
return;
404+
return false;
383405
}
384406

385407
// Okay, there's an application node in the AndroidManifest.xml file.
@@ -411,6 +433,8 @@ private static void AddBroadcastReceiver(XmlDocument manifest)
411433
{
412434
UnityEngine.Debug.Log("[Adjust]: It seems like you are already using Adjust broadcast receiver. Yay.");
413435
}
436+
437+
return false;
414438
}
415439
else
416440
{
@@ -429,6 +453,8 @@ private static void AddBroadcastReceiver(XmlDocument manifest)
429453
applicationNode.AppendChild(receiverElement);
430454

431455
UnityEngine.Debug.Log("[Adjust]: Adjust broadcast receiver successfully added to your app's AndroidManifest.xml file.");
456+
457+
return true;
432458
}
433459
}
434460

Assets/Adjust/Windows/AdjustWindows.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace com.adjust.sdk
1717
{
1818
public class AdjustWindows
1919
{
20-
private const string sdkPrefix = "unity4.20.0";
20+
private const string sdkPrefix = "unity4.20.1";
2121
private static bool appLaunched = false;
2222

2323
public static void Start(AdjustConfig adjustConfig)

Assets/Adjust/iOS/AdjustSdk.a

0 Bytes
Binary file not shown.

Assets/Adjust/iOS/AdjustiOS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace com.adjust.sdk
88
#if UNITY_IOS
99
public class AdjustiOS
1010
{
11-
private const string sdkPrefix = "unity4.20.0";
11+
private const string sdkPrefix = "unity4.20.1";
1212

1313
[DllImport("__Internal")]
1414
private static extern void _AdjustLaunchApp(
0 Bytes
Binary file not shown.

Assets/AdjustImei/Editor/AdjustImeiEditor.cs

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void AutorunPostBuildTasks()
5858
}
5959
else
6060
{
61-
EditorUtility.DisplayDialog("Adjust IMEI Plugin", "Adjust IMEI plugin post build tasks from now on WON'T be performed each time you build your app."
61+
EditorUtility.DisplayDialog("Adjust IMEI Plugin", "Adjust IMEI plugin post build tasks from now on WONT be performed each time you build your app."
6262
+ "\n\nPlease, make sure that your app is compatible for usage of the Adjust IMEI plugin by selecting \"Is my app properly configured?\" option from menu.", "OK");
6363
}
6464
}
@@ -122,34 +122,44 @@ private static void RunPostProcessTasksAndroid()
122122
UnityEngine.Debug.Log("[AdjustImei]: User defined AndroidManifest.xml file located in Plugins/Android folder.");
123123
}
124124

125-
// Seems like you already have your own AndroidManifest.xml, we'll now run
125+
// Seems like you already have your own AndroidManifest.xml, well now run
126126
// some checks on it and tweak it a bit if needed to add some stuff which
127127
// our native Android IMEI plugin needs so that it can run properly.
128128

129-
// Let's open the app's AndroidManifest.xml file.
129+
// Lets open the apps AndroidManifest.xml file.
130130
XmlDocument manifestFile = new XmlDocument();
131131
manifestFile.Load(appManifestPath);
132-
132+
133+
bool manifestHasChanged = false;
134+
133135
// Add needed permissions if they are missing.
134-
AddPermissions(manifestFile);
136+
manifestHasChanged |= AddPermissions(manifestFile);
135137

136-
// Save the changes.
137-
manifestFile.Save(appManifestPath);
138+
if (manifestHasChanged)
139+
{
140+
// Save the changes.
141+
manifestFile.Save(appManifestPath);
138142

139-
// Clean the manifest file.
140-
CleanManifestFile(appManifestPath);
143+
// Clean the manifest file.
144+
CleanManifestFile(appManifestPath);
141145

142-
UnityEngine.Debug.Log("[AdjustImei]: App's AndroidManifest.xml file check and potential modification completed.");
143-
UnityEngine.Debug.Log("[AdjustImei]: Please check if any error message was displayed during this process "
144-
+ "and make sure to fix all issues in order to properly use the Adjust IMEI plugin in your app.");
146+
UnityEngine.Debug.Log("[AdjustImei]: App’s AndroidManifest.xml file check and potential modification completed.");
147+
UnityEngine.Debug.Log("[AdjustImei]: Please check if any error message was displayed during this process "
148+
+ "and make sure to fix all issues in order to properly use the Adjust IMEI plugin in your app.");
149+
}
150+
else
151+
{
152+
UnityEngine.Debug.Log("[AdjustImei]: App’s AndroidManifest.xml file check completed.");
153+
UnityEngine.Debug.Log("[AdjustImei]: No modifications performed due to app’s AndroidManifest.xml file compatibility.");
154+
}
145155
}
146156

147-
private static void AddPermissions(XmlDocument manifest)
157+
private static bool AddPermissions(XmlDocument manifest)
148158
{
149-
// The Adjust IMEI plugin needs following permissions to be added to you app's manifest file:
159+
// The Adjust IMEI plugin needs following permissions to be added to you apps manifest file:
150160
// <uses-permission android:name="android.permission.READ_PHONE_STATE" />
151161

152-
UnityEngine.Debug.Log("[AdjustImei]: Checking if all permissions needed for the Adjust IMEI plugin are present in the app's AndroidManifest.xml file.");
162+
UnityEngine.Debug.Log("[AdjustImei]: Checking if all permissions needed for the Adjust IMEI plugin are present in the apps AndroidManifest.xml file.");
153163

154164
bool hasReadPhoneStatePermission = false;
155165
XmlElement manifestRoot = manifest.DocumentElement;
@@ -169,19 +179,24 @@ private static void AddPermissions(XmlDocument manifest)
169179
}
170180
}
171181

182+
bool manifestHasChanged = false;
183+
172184
// If android.permission.READ_PHONE_STATE permission is missing, add it.
173185
if (!hasReadPhoneStatePermission)
174186
{
175187
XmlElement element = manifest.CreateElement("uses-permission");
176188
element.SetAttribute("android__name", "android.permission.READ_PHONE_STATE");
177189
manifestRoot.AppendChild(element);
178-
UnityEngine.Debug.Log("[AdjustImei]: android.permission.READ_PHONE_STATE permission successfully added to your app's AndroidManifest.xml file.");
190+
UnityEngine.Debug.Log("[AdjustImei]: android.permission.READ_PHONE_STATE permission successfully added to your app’s AndroidManifest.xml file.");
191+
manifestHasChanged = true;
179192
}
180193
else
181194
{
182-
UnityEngine.Debug.Log("[AdjustImei]: Your app's AndroidManifest.xml file already contains android.permission.READ_PHONE_STATE permission.");
195+
UnityEngine.Debug.Log("[AdjustImei]: Your apps AndroidManifest.xml file already contains android.permission.READ_PHONE_STATE permission.");
183196
UnityEngine.Debug.Log("[AdjustImei]: All good.");
184197
}
198+
199+
return manifestHasChanged;
185200
}
186201

187202
private static void CleanManifestFile(String manifestPath)
@@ -214,9 +229,9 @@ private static bool DoesAppHaveAllThePermissions()
214229
}
215230

216231
// Seems like you already have your own AndroidManifest.xml.
217-
// We'll now check if all the permissions needed by the plugin are added.
232+
// Well now check if all the permissions needed by the plugin are added.
218233

219-
// Let's open the app's AndroidManifest.xml file.
234+
// Lets open the apps AndroidManifest.xml file.
220235
XmlDocument manifestFile = new XmlDocument();
221236
manifestFile.Load(appManifestPath);
222237

@@ -238,4 +253,4 @@ private static bool DoesAppHaveAllThePermissions()
238253

239254
return false;
240255
}
241-
}
256+
}

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
### Version 4.20.1 (21st February 2020)
2+
#### Fixed
3+
- Fixed usage of deprecated `TargetGuidByName` API as of Unity 2019.3.0 (thanks to @epsmarkh).
4+
- Fixed unnecessary saving of `AndroidManifest.xml` file whose content was not changed during post build process (thanks to @nanasi880).
5+
6+
#### Native SDKs
7+
- [[email protected]][ios_sdk_v4.20.0]
8+
- [[email protected]][android_sdk_v4.20.0]
9+
- [[email protected]][windows_sdk_v4.17.0]
10+
11+
---
12+
113
### Version 4.20.0 (16th January 2020)
214
#### Added
315
- Added external device ID support.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.20.0
1+
4.20.1

doc/english/migration/migrate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Migrate your Adjust SDK for Unity3d to 4.20.0 from 3.4.4
1+
## Migrate your Adjust SDK for Unity3d to 4.20.1 from 3.4.4
22

33
### Migration procedure
44

ext/android/sdk

0 commit comments

Comments
 (0)