Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 87 additions & 2 deletions .af-e2e/test-plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"plan_id": "unity-e2e",
"plugin": "unity",
"version": "1.0.0",
"description": "End-to-end test plan for the AppsFlyer Unity plugin. CI imports the generated appsflyer-unity-plugin-<version>.unitypackage into test-app/ before building, so E2E validates the same regular customer artifact that RC publish attaches. Covers seven scenarios: cold launch, background deep link, foreground deep link, custom event with parameters, identity APIs round-trip, consent / SDK stop toggle, and (iOS-only) Universal Link re-open through the scene delegate's scene:continueUserActivity:. NOTE: the scene delegate's true cold-launch path (scene:willConnectToSession:options:, DELIVERY-115275's original trigger) is NOT exercised by phase_7 or any other automation here - UISceneConnectionOptions has no public initializer, so the QA harness cannot fabricate that event and can only drive the warm re-open swizzle. That branch remains manually/E2E-unverified. Mapped to E2E-001..E2E-007 in appsflyer-mobile-plugin-tooling/contracts/e2e-test-contract.md.",
"description": "End-to-end test plan for the AppsFlyer Unity plugin. CI imports the generated appsflyer-unity-plugin-<version>.unitypackage into test-app/ before building, so E2E validates the same regular customer artifact that RC publish attaches. Covers nine scenarios: cold launch, background deep link, foreground deep link, custom event with parameters, identity APIs round-trip, consent / SDK stop toggle, (iOS-only) Universal Link re-open through the scene delegate's scene:continueUserActivity:, and Purchase Connector integration (Android-only phase_8, iOS-only phase_9). NOTE: the scene delegate's true cold-launch path (scene:willConnectToSession:options:, DELIVERY-115275's original trigger) is NOT exercised by phase_7 or any other automation here - UISceneConnectionOptions has no public initializer, so the QA harness cannot fabricate that event and can only drive the warm re-open swizzle. That branch remains manually/E2E-unverified. Mapped to E2E-001..E2E-009 in appsflyer-mobile-plugin-tooling/contracts/e2e-test-contract.md.",
"platforms": ["android", "ios"],
"schema_version": "1.0.0",
"tooling_contract_ref": "E2E-001, E2E-002, E2E-003, E2E-004, E2E-005, E2E-006, E2E-007"
"tooling_contract_ref": "E2E-001, E2E-002, E2E-003, E2E-004, E2E-005, E2E-006, E2E-007, E2E-008, E2E-009"
},

"config": {
Expand Down Expand Up @@ -435,6 +435,91 @@
"fail_action": "fail"
}
]
},
{
"id": "phase_8",
"name": "Purchase Connector integration (Android)",
"scenario_ref": "E2E-008",
"description": "Android-only. Fresh install. The test app calls AppsFlyerPurchaseConnector init/build/startObservingTransactions before start(). Verifies com.appsflyer:purchase-connector is in the APK and actually starts: the native SDK logs Start Observing Transactions and the Play Billing connection callback, and the C# guard did not fall back to no-ops. Regression guard for DELIVERY-137580, where the dependency was commented out of AppsFlyerDependencies.xml and Purchase Connector silently did nothing. No purchase is made; the CI emulator has no Google account, so onBillingSetupFinished reports billing unavailable, which is expected.",
"platforms": ["android"],
"requires_fresh_install": true,
"wait_after_launch_sec": 240,
"checks": [
{
"id": "pc_csharp_calls_done",
"description": "Test app ran the Purchase Connector setup calls",
"type": "log_contains",
"pattern": "[AF_QA][PurchaseConnector] init+build+startObservingTransactions done",
"fail_action": "fail"
},
{
"id": "pc_native_observing",
"description": "Native Purchase Connector started observing transactions (proves purchase-connector is in the APK)",
"type": "log_contains",
"pattern": "[PurchaseConnector]: Start Observing Transactions",
"fail_action": "fail"
},
{
"id": "pc_billing_setup_finished",
"description": "Purchase Connector connected to Play Billing (the callback fires even when billing is unavailable)",
"type": "log_contains",
"pattern": "[PurchaseConnector]: onBillingSetupFinished",
"fail_action": "fail"
},
{
"id": "pc_not_missing",
"description": "C# guard did not fall back to no-ops (its warning carries the [AppsFlyer] tag, so it passes the runner's logcat filter; the native-log checks above are the primary guard)",
"type": "absent",
"patterns": ["Purchase Connector is unavailable on Android"],
"fail_action": "fail"
},
{
"id": "no_fatal_errors",
"description": "No fatal exceptions",
"type": "absent",
"patterns": ["Fatal Exception", "FATAL"],
"fail_action": "fail"
}
]
},
{
"id": "phase_9",
"name": "Purchase Connector integration (iOS)",
"scenario_ref": "E2E-009",
"description": "iOS-only. Fresh install. The test app calls AppsFlyerPurchaseConnector init, setStoreKitVersion(SK2), setIsSandbox(true), build and startObservingTransactions before start(). Verifies the PurchaseConnector framework is linked and actually runs: when it is not linked, AppsFlyeriOSWrapper.mm compiles silent no-op stubs, so the native [PurchaseConnector] logs are the only proof. No purchase is made; the simulator has no App Store account, so StoreKit reports 'No active account', which is expected.",
"platforms": ["ios"],
"requires_fresh_install": true,
"wait_after_launch_sec": 240,
"checks": [
{
"id": "pc_csharp_calls_done",
"description": "Test app ran the Purchase Connector setup calls",
"type": "log_contains",
"pattern": "[AF_QA][PurchaseConnector] init+build+startObservingTransactions done",
"fail_action": "fail"
},
{
"id": "pc_native_sandbox",
"description": "Native PurchaseConnector received setIsSandbox(true) (proves the real framework, not the wrapper stubs, ran)",
"type": "log_contains",
"pattern": "[PurchaseConnector] AppsFlyerARS has been set to Sandbox environment",
"fail_action": "fail"
},
{
"id": "pc_native_cache_resolved",
"description": "Native PurchaseConnector initialised its purchase event cache",
"type": "log_contains",
"pattern": "[PurchaseConnector] Resolved cached PurchaseConnectorEvents",
"fail_action": "fail"
},
{
"id": "no_fatal_errors",
"description": "No fatal exceptions",
"type": "absent",
"patterns": ["Fatal Exception", "FATAL"],
"fail_action": "fail"
}
]
}
],

Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/rc-e2e-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ jobs:
echo "::error::AppsFlyerRpcHandler class missing from built APK (af-android-plugin-bridge dependency likely dropped from mainTemplate.gradle)"
exit 1
fi
echo "--- Purchase Connector PurchaseClient class present in dex? ---"
if strings "$WORKDIR"/classes*.dex | grep -q 'Lcom/appsflyer/api/PurchaseClient;'; then
echo "FOUND"
else
echo "::error::PurchaseClient class missing from built APK (com.appsflyer:purchase-connector dropped from AppsFlyerDependencies.xml or not resolved by EDM4U)"
exit 1
fi
echo "--- distinct com.appsflyer.* package roots baked into dex ---"
strings "$WORKDIR"/classes*.dex | grep -oE '^Lcom/appsflyer/[a-zA-Z_]+' | sort -u

Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/rc-e2e-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,29 @@ jobs:
rm -rf test-app/Build/iOS-Simulator/UnityQATest.app
cp -R "$APP" test-app/Build/iOS-Simulator/UnityQATest.app

- name: Verify Purchase Connector is linked into the .app
run: |
APP=test-app/Build/iOS-Simulator/UnityQATest.app
UF="$APP/Frameworks/UnityFramework.framework/UnityFramework"
# AppsFlyeriOSWrapper.mm compiles silent no-op stubs when PurchaseConnector-Swift.h is
# not found, so the real bridge is proven by UnityFramework referencing the @objc
# PurchaseConnector class (verified with nm on a real build: "(undefined) external
# _OBJC_CLASS_$_PurchaseConnector (from PurchaseConnector)"). Undefined = dynamically
# linked (SPM PurchaseConnector-Dynamic), so the framework must also be embedded;
# defined = statically linked into UnityFramework, nothing to embed.
# (No grep -q: it closes the pipe early and nm's SIGPIPE would fail under pipefail.)
SYMBOLS=$(nm -m "$UF" | grep -E '_OBJC_CLASS_\$_PurchaseConnector( |$)' || true)
echo "$SYMBOLS"
if [[ -z "$SYMBOLS" ]]; then
echo "::error::UnityFramework does not reference the PurchaseConnector class - AppsFlyeriOSWrapper.mm was compiled with the no-op stubs (PurchaseConnector pod/SPM package not resolved)"
exit 1
fi
if echo "$SYMBOLS" | grep '(undefined)' >/dev/null && [[ ! -d "$APP/Frameworks/PurchaseConnector.framework" ]]; then
echo "::error::UnityFramework links PurchaseConnector dynamically but PurchaseConnector.framework is not embedded in UnityQATest.app (dyld would fail at launch)"
exit 1
fi
echo "PurchaseConnector bridge linked into UnityFramework"

- name: Upload xcodebuild log
if: always()
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion Assets/AppsFlyer/AppsFlyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace AppsFlyerSDK
#pragma warning disable CS1998
public class AppsFlyer : MonoBehaviour
{
public static readonly string kAppsFlyerPluginVersion = "7.0.41";
public static readonly string kAppsFlyerPluginVersion = "7.0.42";
public static string CallBackObjectName = null;
private static EventHandler onSessionReady;
private static Action<string> onConversionDataSuccessCallback;
Expand Down
21 changes: 11 additions & 10 deletions Assets/AppsFlyer/AppsFlyerPurchaseConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,11 @@ private void Awake()
private static bool _connectorUnavailableWarned;
private static bool _connectorLookupFailed;

// purchase-connector is currently disabled in AppsFlyerDependencies.xml (AGP 8 namespace
// collision with af-android-sdk - see review_processed.md #16), but AppsFlyerAndroidWrapper
// still directly imports its types. That turns every Purchase Connector call below into an
// unguarded NoClassDefFoundError/ClassNotFoundException at the point of first use instead of
// a build-time failure. Resolve/call through here so integrators who don't use Purchase
// Connector are unaffected, and those who do get one clear logged warning instead of a crash.
// AppsFlyerAndroidWrapper imports purchase-connector types, but the wrapper only has a
// compileOnly dependency on it. If the app ends up without purchase-connector (e.g. the
// dependency was excluded or EDM4U resolution was skipped), every call below would throw
// NoClassDefFoundError/ClassNotFoundException at first use. Resolve/call through here so the
// app gets one clear logged warning instead of a crash.
private static bool TryGetConnector(out AndroidJavaClass connector)
{
if (_connectorLookupFailed)
Expand Down Expand Up @@ -294,10 +293,12 @@ private static void WarnConnectorUnavailable(Exception e)
{
if (_connectorUnavailableWarned) return;
_connectorUnavailableWarned = true;
Debug.LogWarning("[AppsFlyer] Purchase Connector is unavailable on Android (the " +
"purchase-connector dependency is currently disabled due to an AGP 8 namespace " +
"collision with af-android-sdk - see Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml). " +
"Purchase Connector calls will be no-ops until this is resolved upstream. " + e);
Debug.LogWarning("[AppsFlyer] Purchase Connector is unavailable on Android. Possible causes: " +
"(1) com.appsflyer:purchase-connector is missing from the build - make sure External " +
"Dependency Manager resolved Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml; " +
"(2) Google Play Billing Library 8 is missing or older - Purchase Connector requires the " +
"app to provide com.android.billingclient:billing 8.x (e.g. Unity IAP 5.x). " +
"Purchase Connector calls will be no-ops. " + e);
}
#endif

Expand Down
7 changes: 4 additions & 3 deletions Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
itself is installed on the device, surfacing as a ClassNotFoundException in
the "gaidError" field of outgoing SDK requests. -->
<androidPackage spec="com.google.android.gms:play-services-ads-identifier:18.3.0"></androidPackage>
<!-- purchase-connector shares a manifest package with af-android-sdk; AGP 8 namespace
collision. Disabled until AppsFlyer publishes distinct AGP namespaces upstream. -->
<!-- <androidPackage spec="com.appsflyer:purchase-connector:2.3.0"></androidPackage> -->
<!-- purchase-connector and af-android-sdk both use the manifest package "com.appsflyer".
AGP 8.x only warns about it; AGP 9+ fails the build unless android.uniquePackageNames=false,
which AppsFlyerGradlePropertiesProcessor adds to the generated gradle.properties. -->
<androidPackage spec="com.appsflyer:purchase-connector:2.3.0"></androidPackage>
</androidPackages>

<!-- iOS dependencies via Swift Package Manager (EDM4U 1.2.187+). Each remoteSwiftPackage's
Expand Down
63 changes: 63 additions & 0 deletions Assets/AppsFlyer/Editor/AppsFlyerGradlePropertiesProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Not guarded by UNITY_ANDROID: a scripted Android build started while the Editor's active platform
// is iOS/Standalone would otherwise compile without this hook. IPostGenerateGradleAndroidProject
// lives in UnityEditor.CoreModule, so this compiles without the Android module, and Unity only
// invokes it for Android builds.
#if !APPSFLYER_DISABLE_UNIQUE_PACKAGE_NAMES_FIX
using System.IO;
using UnityEditor.Android;
using UnityEngine;

namespace AppsFlyerSDK
{
// com.appsflyer:purchase-connector and com.appsflyer:af-android-sdk share the manifest
// package "com.appsflyer". AGP 8.x only warns about it, but AGP 9.0 changed the default of
// android.uniquePackageNames to true, which turns it into a build error. This adds
// android.uniquePackageNames=false to the generated gradle.properties so that apps building
// with AGP 9+ (Unity 6000.0.79f1+, 6000.3.17f1+, ...) don't have to set it by hand.
//
// The property is only added when the project doesn't already set it, so an explicit
// value in gradleTemplate.properties always wins. Define the scripting symbol
// APPSFLYER_DISABLE_UNIQUE_PACKAGE_NAMES_FIX to turn this off entirely.
public class AppsFlyerGradlePropertiesProcessor : IPostGenerateGradleAndroidProject
{
private const string PropertyKey = "android.uniquePackageNames";

public int callbackOrder => 0;

public void OnPostGenerateGradleAndroidProject(string path)
{
// path points to the unityLibrary module; gradle.properties lives in the root project.
string propertiesPath = Path.GetFullPath(Path.Combine(path, "..", "gradle.properties"));
if (!File.Exists(propertiesPath))
{
Debug.LogWarning("[AppsFlyer] gradle.properties not found at " + propertiesPath +
". If the build fails with \"Namespace 'com.appsflyer' is used in multiple modules\", add " +
PropertyKey + "=false to Assets/Plugins/Android/gradleTemplate.properties.");
return;
}

string contents = File.ReadAllText(propertiesPath);
if (DefinesProperty(contents, PropertyKey)) return;

string separator = contents.Length == 0 || contents.EndsWith("\n") ? "" : "\n";
File.AppendAllText(propertiesPath, separator +
"# Added by AppsFlyer: purchase-connector and af-android-sdk share the namespace com.appsflyer (AGP 9+).\n" +
PropertyKey + "=false\n");
}

private static bool DefinesProperty(string contents, string key)
{
foreach (string rawLine in contents.Split('\n'))
{
string line = rawLine.Trim();
if (line.Length == 0 || line[0] == '#' || line[0] == '!') continue;

int end = line.IndexOfAny(new[] { '=', ':', ' ', '\t' });
string lineKey = end < 0 ? line : line.Substring(0, end);
if (lineKey == key) return true;
}
return false;
}
}
}
#endif
11 changes: 11 additions & 0 deletions Assets/AppsFlyer/Editor/AppsFlyerGradlePropertiesProcessor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/AppsFlyer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "appsflyer-unity-plugin",
"displayName": "AppsFlyer",
"description": "AppsFlyer Unity plugin",
"version": "7.0.41",
"version": "7.0.42",
"unity": "2023.1",
"license": "MIT"
}
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Versions

## v7.0.42
* **Fix (DELIVERY-137580):** Android Purchase Connector is enabled again. `com.appsflyer:purchase-connector:2.3.0`
had been commented out in `AppsFlyerDependencies.xml` because of a manifest-package collision with
`af-android-sdk` (both `com.appsflyer`), so Purchase Connector calls on Android were no-ops. AGP 8.x
only warns about the collision; AGP 9+ fails the build unless `android.uniquePackageNames=false` is set.
The plugin now adds `android.uniquePackageNames=false` to the generated `gradle.properties` at build
time (new `AppsFlyerGradlePropertiesProcessor`), unless the project already sets the property. Define
`APPSFLYER_DISABLE_UNIQUE_PACKAGE_NAMES_FIX` to opt out (see README).
Purchase Connector requires the app to provide Google Play Billing Library 8.x (e.g. Unity IAP 5.x);
Billing 7 / Unity IAP 4.x is not supported. Apps that don't call `AppsFlyerPurchaseConnector` are
unaffected.

* Update af-android-plugin-bridge version - 7.0.13
* Update AppsFlyerRPC version - 7.0.41
* Update Android unity-wrapper version - 7.0.16
* Update iOS Purchase Connector version - 7.0.4
* Update Android Purchase Connector version - 2.3.0
* Unity plugin version - 7.0.42
## v7.0.41
* **Fix (DELIVERY-135217):** `AFMiniJSON` formatted and parsed numbers using the device's current
culture. On comma-decimal locales (e.g. `vi-VN`, `de-DE`, `fr-FR`, `ru-RU`) RPC requests carried
Expand Down
Loading
Loading