firebase-unity-sdk: Dynamic Links crashes with il2cpp on Android due to Proguard stripping
Platforms and SDKs
Unity editor version: 2019.1.11 f1 Firebase Unity SDK version: 6.2.0 Firebase plugins in use (Auth, Database, etc.): Auth, DynamicLinks Additional SDKs you are using (Facebook, AdMob, etc.): GoogleSignIn (Github link) Facebook, AdMob Platform you are using the Unity editor on (Mac, Windows, or Linux): Windows Platform you are targeting (iOS, Android, and/or desktop): Android
Context: I’m using Firebase Dynamic Links Unity SDK to create dynamic referral links in my game. The script I wrote generates a long dynamic link from a DynamicLinkComponents instance.
Code:
DynamicLinkComponents dynamicLink = new DynamicLinkComponents(
new Uri("https://flareupdigital.com/?invitedby=" + referralID),
"https://flareupdigital.page.link"
);
Debug.Log(dynamicLink.LongDynamicLink); // Works fine with "Mono", Throws exception with "il2cpp"
Issue: When compiled with “il2cpp” scripting backend, dynamic link generation fails in device with the following error:
ApplicationException: internal::IsInitialized() at Firebase.DynamicLinks.FirebaseDynamicLinks.GetLongLinkInternal(Firebase.DynamicLinks.DynamicLinkComponentsInternal components)
(Full stack here - log.txt)
Important Notes: The script WORKS FINE in our devices (Google Pixel 2 XL, OnePlus 7, etc.) if compiled with the “Mono” scripting backend in Unity.
Additional References: This issue has been discussed before, but there was no solution posted or the solution does not work:
- Suggested “Force Resolve” in the PlayServiceResolver, but that did not work for me
- No solution posted
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 23 (5 by maintainers)
Hey guys,
we found a way to resolve the issue! The problem was that proguard stripped out some dynamic link libraries (and also some google internal stuff).
ALL of the following proguard lines are REQUIRED to get it working: -keep,includedescriptorclasses public class com.google.firebase.dynamiclinks* { *; }
-keep class com.google.firebase** { *; } -keep class com.google.firebase.appinvite** { *; } -keep class com.google.firebase.dynamiclinks** { *; } -keep class com.google.firebase.dynamiclinks.FirebaseDynamicLinks** { *; } -keep class com.google.android.gms.internal** { *; } -keep class com.google.android.gms** { *; }