urbanairship / android-library

Urban Airship Android SDK
Other
109 stars 123 forks source link

Airship Version 15.x and 16.x crash on startup - Accengage SDK Firebase Interaction #196

Closed avalanchas closed 2 years ago

avalanchas commented 2 years ago

Preliminary Info

What Airship dependencies are you using?

implementation "com.ad4screen.sdk:A4SSDK:4.1.8"
implementation "com.ad4screen.sdk:plugin-firebase-messaging:4.1.8"
implementation "com.urbanairship.android:urbanairship-core:16.0.0"
implementation "com.urbanairship.android:urbanairship-fcm:16.0.0"
implementation "com.urbanairship.android:urbanairship-automation:16.0.0"

Firebase dependencies (probably relevant for this issue):

implementation platform("com.google.firebase:firebase-bom:28.4.2")
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'

Crash occurs in Airship version 15.0.0, 15.1.0 and 16.0.0 Crash does not occur in Airship version 14.0.0

What are the versions of any relevant development tools you are using?

System Info

Android Studio Arctic Fox | 2020.3.1 Patch 3
Build #AI-203.7717.56.2031.7784292, built on October 1, 2021
Runtime version: 11.0.10+0-b96-7249189 amd64
VM: OpenJDK 64-Bit Server VM by Oracle Corporation
Windows 10 10.0

Gradle

Gradle: 7.2
com.android.tools.build:gradle:7.0.3

This crash is reproducible in debug and release builds, so it cannot be a Proguard problem

Report

What unexpected behavior are you seeing?

App crashes soon after start, because it tries to access the FirebaseInstanceId class and can't find it. This seems to be some kind of weird interaction between the Accengage A4S SDK and the firebase SDK. Since the behaviour appears only in 15.x upwards, I suspect this has something to do with the changes to the Firebase sender ID mentioned in the changelog for that version

I have read the Migration Guide but it does not address this issue and I do not use the FEATURE_CONTACTS

What is the expected behavior?

No crashes, as in version 14.x.x

What are the steps to reproduce the unexpected behavior?

  1. Update Airship SDK to >= 15.0.0 in an app that uses both Accengage and Airship dependencies
  2. Clean install app
  3. Accengage initialises itself, you can still see the usual "Accengage logging must be disabled in prod..." Toast pop up, then the app crashes

Do you have logging for the issue?

2021-11-01 10:24:25.848 19580-19849/de.radio.android E/AndroidRuntime: FATAL EXCEPTION: Binder:19580_5
    Process: de.radio.android, PID: 19580
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId;
        at com.ad4screen.sdk.plugins.fcm.FCM.register(FCM.java:59)
        at com.ad4screen.sdk.s.b.b(SourceFile:6)
        at com.ad4screen.sdk.l$a.onTransact(SourceFile:11)
        at android.os.Binder.execTransactInternal(Binder.java:1179)
        at android.os.Binder.execTransact(Binder.java:1143)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceId" on path: DexPathList[[zip file "/data/app/~~LHJeu62_rgqBFk-BPZyiug==/de.radio.android-hDLE9vGgwbuXMXhgCGncnQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~LHJeu62_rgqBFk-BPZyiug==/de.radio.android-hDLE9vGgwbuXMXhgCGncnQ==/lib/arm64, /system/lib64, /system_ext/lib64, /product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:218)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.ad4screen.sdk.plugins.fcm.FCM.register(FCM.java:59) 
        at com.ad4screen.sdk.s.b.b(SourceFile:6) 
        at com.ad4screen.sdk.l$a.onTransact(SourceFile:11) 
        at android.os.Binder.execTransactInternal(Binder.java:1179) 
        at android.os.Binder.execTransact(Binder.java:1143) 
rlepinski commented 2 years ago

Google removed firebase-iid around v21 of FCM. You can probably just add firebase-iid package to your dependencies to resolve the issue.

This is an Accengage SDK issue not Airship SDK so it wont be in our migration guides. I will forward this on to the team though

avalanchas commented 2 years ago

Hi, that sounds reasonable and I will test in the coming days, but I wonder why the upgrade in the Airship SDK leads to this behaviour then. Maybe this dependency was transitively declared in the older Airship versions and is now missing, because it was fulfilled through previous Airship versions and is now not fulfilled anymore?

I am very hesitant to declare firebase-iid myself as it has been deprecated since late 2020

Edit: firebase-installations, the successor to firebase-iid also might provide this class. Still seeing the crash now, I will do more testing.

avalanchas commented 2 years ago

As far as I can tell only adding firebase-iid fixes the crash. Can you please comment on why this is the case, even in an app where - as mentioned above - nothing but the Airship SDK update changes?

rlepinski commented 2 years ago

The Airship SDK is keeping up with latest version of FCM, so when you use a new version of Airship it will force a newer version of FCM as a transitive dependency.

Accengage SDK is depending on an older version with firebase-iid, it needs to be updated but adding it is a quick workaround for now.