Skip to content

Commit 6a3eba5

Browse files
authored
Merge pull request #794 from immutable/feat/audience-installreferrer-maven
feat(audience): resolve install referrer via Maven instead of bundling the AAR
2 parents b3c2a16 + 13e40ba commit 6a3eba5

7 files changed

Lines changed: 59 additions & 41 deletions

File tree

examples/audience/Assets/Plugins/Android/mainTemplate.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ apply plugin: 'com.android.library'
2222
dependencies {
2323
implementation fileTree(dir: 'libs', include: ['*.jar'])
2424
**DEPS**
25+
// Google Play Install Referrer Library, resolved from Maven (the Audience
26+
// package no longer bundles it as an .aar - it conflicted with other SDKs).
27+
// EDM4U projects get it automatically from ImmutableAudienceDependencies.xml;
28+
// this sample has no EDM4U, so it declares the dependency manually.
29+
implementation 'com.android.installreferrer:installreferrer:2.2'
30+
2531
// Uncomment to enable GAID collection (requires AUDIENCE_MOBILE_ATTRIBUTION
2632
// scripting define + AudienceConfig.EnableMobileAttribution). Without this
2733
// line the SDK still builds and runs, but `gaid` / `gaidLimitAdTracking`
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
EDM4U dependency declaration. The Google Play Install Referrer Library is
4+
resolved from Maven rather than bundled as an .aar: bundled .aars can't be
5+
de-duplicated by Gradle, so shipping installreferrer-2.2.aar directly caused
6+
class/version conflicts with other SDKs. Declaring it here lets Gradle pick a
7+
single highest version.
8+
9+
Requires EDM4U. Without it, add the dependency manually to
10+
Assets/Plugins/Android/mainTemplate.gradle:
11+
implementation 'com.android.installreferrer:installreferrer:2.2'
12+
13+
play-services-ads-identifier (GAID) is intentionally NOT declared here - left
14+
to the studio, so games that don't collect the advertising ID never declare
15+
the AD_ID permission (see AndroidManifestPostProcessor).
16+
-->
17+
<dependencies>
18+
<androidPackages>
19+
<androidPackage spec="com.android.installreferrer:installreferrer:2.2">
20+
<repositories>
21+
<repository>https://maven.google.com</repository>
22+
</repositories>
23+
</androidPackage>
24+
</androidPackages>
25+
</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)