Skip to content

Commit a11ac31

Browse files
nattb8claude
andcommitted
feat(audience): resolve install referrer via Maven instead of bundling the AAR
Bundled AARs can't be de-duplicated by Gradle, so shipping installreferrer-2.2.aar directly caused class/version conflicts when a game pulled the same library in via another SDK. Declare it as a Maven dependency through EDM4U (Editor/ImmutableAudienceDependencies.xml) and document a manual mainTemplate.gradle fallback for projects without EDM4U. The AUDIENCE_MOBILE_ATTRIBUTION define still gates the C# JNI code; the defensive proguard keep-rules are retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b3c2a16 commit a11ac31

6 files changed

Lines changed: 57 additions & 41 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
External Dependency Manager for Unity (EDM4U) dependency declaration.
4+
5+
The Google Play Install Referrer Library is resolved from Maven instead of
6+
being bundled as a prebuilt .aar. Bundled .aars cannot be de-duplicated by
7+
Gradle, so shipping installreferrer-2.2.aar directly caused class/version
8+
conflicts when a game already pulled in the same library via another SDK.
9+
Declaring it here lets Gradle's resolver pick a single, highest version.
10+
11+
Requires EDM4U (com.google.external-dependency-manager) in the project.
12+
Studios that do not use EDM4U should instead add the dependency manually:
13+
14+
// Assets/Plugins/Android/mainTemplate.gradle, dependencies { }
15+
implementation 'com.android.installreferrer:installreferrer:2.2'
16+
17+
play-services-ads-identifier (GAID) is intentionally NOT declared here - it
18+
is left for the studio to add so that games which do not collect the
19+
advertising ID never declare the AD_ID permission. See AndroidManifestPostProcessor.
20+
-->
21+
<dependencies>
22+
<androidPackages>
23+
<androidPackage spec="com.android.installreferrer:installreferrer:2.2">
24+
<repositories>
25+
<repository>https://maven.google.com</repository>
26+
</repositories>
27+
</androidPackage>
28+
</androidPackages>
29+
</dependencies>

src/Packages/Audience/Editor/ImmutableAudienceDependencies.xml.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Audience/README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,29 @@ Press Play; `ImmutableAudience.Initialized` returns `true` and `AnonymousId` bec
4747
- Integration guide and API reference: <https://docs.immutable.com/docs/products/audience/unity-sdk>
4848
- Sample Unity project: [`examples/audience`](https://github.com/immutable/unity-immutable-sdk/tree/main/examples/audience)
4949

50-
## Vendored dependencies
50+
## Android dependencies
5151

52-
The package vendors prebuilt third-party AARs for mobile attribution. They are only included in your build when the corresponding scripting define is set; without the define they're stripped via `defineConstraints` on the plugin meta files.
52+
Mobile install attribution (the `AUDIENCE_MOBILE_ATTRIBUTION` define) needs the Google Play Install Referrer Library. The package does **not** bundle it as a prebuilt `.aar` — bundled AARs can't be de-duplicated by Gradle, so shipping `installreferrer-2.2.aar` directly caused class/version conflicts when a game already pulled in the same library via another SDK. Instead it's resolved from Maven:
5353

54-
| File | Version | Source | Required define |
55-
| --- | --- | --- | --- |
56-
| `Runtime/Plugins/Android/installreferrer-2.2.aar` | 2.2 | [maven.google.com](https://maven.google.com/web/index.html#com.android.installreferrer:installreferrer:2.2) | `AUDIENCE_MOBILE_ATTRIBUTION` |
54+
| Dependency | Version | Source |
55+
| --- | --- | --- |
56+
| `com.android.installreferrer:installreferrer` | 2.2 | [maven.google.com](https://maven.google.com/web/index.html#com.android.installreferrer:installreferrer:2.2) |
5757

58-
`Runtime/Plugins/Android/proguard-user.txt` ships explicit R8 keep rules for the Install Referrer Library. Unity's gradle build merges it automatically when the AAR is included.
58+
**With [EDM4U](https://github.com/googlesamples/unity-jar-resolver) (recommended):** no action needed. `Editor/ImmutableAudienceDependencies.xml` declares the dependency and EDM4U's Android Resolver fetches it, resolving any version conflict with other SDKs to a single highest version. Install EDM4U as a project prerequisite — do not embed a second copy.
5959

60-
Before tagging a release, check `maven.google.com` for newer versions of any vendored dependency and bump the pinned filename if needed.
60+
**Without EDM4U:** add the dependency to your `Assets/Plugins/Android/mainTemplate.gradle`:
61+
62+
```gradle
63+
dependencies {
64+
implementation 'com.android.installreferrer:installreferrer:2.2'
65+
}
66+
```
67+
68+
`Runtime/Plugins/Android/proguard-user.txt` ships explicit R8 keep rules for the Install Referrer Library; Unity's gradle build merges them regardless of how the dependency is resolved.
69+
70+
`play-services-ads-identifier` (GAID) is intentionally left for the studio to add, so games that don't collect the advertising ID never declare the `AD_ID` permission.
71+
72+
Before tagging a release, check `maven.google.com` for a newer version and bump the pinned version above and in `ImmutableAudienceDependencies.xml` if needed.
6173

6274
## License
6375

Binary file not shown.

src/Packages/Audience/Runtime/Plugins/Android/installreferrer-2.2.aar.meta

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Packages/Audience/Runtime/Plugins/Android/proguard-user.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Keep Google Play Install Referrer Library symbols.
22
#
3-
# The AAR (installreferrer-2.2.aar) ships consumer rules in
3+
# The installreferrer AAR (resolved from Maven via EDM4U or a manual gradle
4+
# dependency - see README) ships consumer rules in
45
# META-INF/com.android.tools/proguard/proguard.txt and Unity's gradle build
56
# auto-merges them, but R8 fullMode in Unity 2022.3+ has been observed to
67
# discard merged consumer rules in some studio configurations. These

0 commit comments

Comments
 (0)