snowplow / snowplow-android-tracker

Snowplow event tracker for Android. Add analytics to your Android apps and games
http://snowplowanalytics.com
Apache License 2.0
110 stars 63 forks source link

App crashes at startup when initializing Snowplow tracker #634

Closed sofi-kry closed 1 year ago

sofi-kry commented 1 year ago

Describe the bug

App crashes at startup when initializing Snowplow tracker.

FATAL EXCEPTION: main
Process: s.android.debug, PID: 14873
java.lang.AbstractMethodError: abstract method "void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner)"
    at androidx.lifecycle.DefaultLifecycleObserverAdapter.onStateChanged(DefaultLifecycleObserverAdapter.kt:24)
    at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
    at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
    at com.snowplowanalytics.core.session.ProcessObserver$Companion.initialize$lambda$0(ProcessObserver.kt:70)
    at com.snowplowanalytics.core.session.ProcessObserver$Companion.$r8$lambda$R0GHTIeQctHh1chVh7NT2KdbPok(Unknown Source:0)
    at com.snowplowanalytics.core.session.ProcessObserver$Companion$$ExternalSyntheticLambda0.run(Unknown Source:0)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7918)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

To Reproduce Build app from command line with assemble task.

Expected behavior No crash.

Screenshots N/A

Device information (please complete the following information):

Additional context Snowplow version: 5.4.2 Gradle: 8.3 AGP: 8.1.1

matus-tomlein commented 1 year ago

Hi @sofi-kry, thank you for reporting this!

Could you please provide us with a small reproducible app? I have tried to reproduce the problem in a blank Android app but didn't get the build error that you reported.

sofi-kry commented 1 year ago

Hi @matus-tomlein, thanks for your reply!

In trying to create what you asked, I discovered that the issue was in how we were adding the snowplow dependency. Since the initial integration we've had the @aar at the end of the dependency and removing it fixed the crash 🤷‍♀️

Before:

implementation "com.snowplowanalytics:snowplow-android-tracker:5.4.2@aar"

After:

implementation "com.snowplowanalytics:snowplow-android-tracker:5.4.2"

Thank you!

matus-tomlein commented 1 year ago

Thanks for the update @sofi-kry, glad you could figure it out!