klaviyo / klaviyo-android-sdk

SDK that allows users to incorporate Klaviyo's event and person tracking functionality within native Android applications. Written in Kotlin
https://klaviyo.github.io/klaviyo-android-sdk/
MIT License
7 stars 2 forks source link

The initial sdk crashed. Procedure #182

Closed HuangBiaoHb closed 2 months ago

HuangBiaoHb commented 2 months ago

Checklist

Description

The Klaviyo.initialize method crashes, Should I specify the kotlin version?

My version of kotlin: 1.7.20
My version of gradel: 8.3

Expected behavior

Can initialize normally

Actual behavior

crashes
 java.lang.ClassNotFoundException: Didn't find class "kotlin.enums.EnumEntriesKt" on path: DexPathList[[dex file "/data/data/com.renpho.health/code_cache/.overlay/base.apk/classes23.dex", zip file "/data/app/~~6Up3Lg5KenJ-kNQBvf88oQ==/com.renpho.health-2tg64saQQ6rPFm49PH2jdA==/base.apk"],nativeLibraryDirectories=[/data/app/~~6Up3Lg5KenJ-kNQBvf88oQ==/com.renpho.health-2tg64saQQ6rPFm49PH2jdA==/lib/arm64, /data/app/~~6Up3Lg5KenJ-kNQBvf88oQ==/com.renpho.health-2tg64saQQ6rPFm49PH2jdA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
                                                                                                    │   at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
                                                                                                    │   at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                                                    │   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                                    │  Caused by: java.lang.NoClassD
                                                                                                    └────────────────────────────────────────────────────────────────────────────────────────────────────────────────
2024-08-28 16:21:17.620 25398-25398 CrashHandler            com.renpho.health                    E   
                                                                                                    ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                    │ efFoundError: Failed resolution of: Lkotlin/enums/EnumEntriesKt;
                                                                                                    │   at com.klaviyo.core.config.Log$Level.<clinit>(Log.kt:15)
                                                                                                    │   at com.klaviyo.core.KLog.<clinit>(KLog.kt:60)
                                                                                                    │   at com.klaviyo.core.Registry$1.invoke(Registry.kt:69)
                                                                                                    │   at com.klaviyo.core.Registry.getLog(Registry.kt:170)
                                                                                                    │   at com.klaviyo.core.networking.KlaviyoNetworkMonitor.initializeNetworkListener(KlaviyoNetworkMonitor.kt:117)
                                                                                                    │   at com.klaviyo.core.networking.KlaviyoNetworkMonitor.onNetworkChange(KlaviyoNetworkMonitor.kt:62)
                                                                                                    │   at com.klaviyo.core.networking.KlaviyoNetworkMonitor.<clinit>(KlaviyoNetworkMonitor.kt:51)
                                                                                                    │   at com.klaviyo.core.Registry.getNetworkMonitor(Registry.kt:50)
                                                                                                    │   at com.klaviyo.analytics.networking.KlaviyoApiClient.startService(KlaviyoApiClient.kt:45)
                                                                                                    │   at com.klaviyo.analytics.Klaviyo$initialize$1.invoke(Klaviyo.kt:81)
                                                                                                    │   at com.klaviyo.analytics.Klaviyo$initialize$1.invoke(Klaviyo.kt:65)

Steps to reproduce

1. application -> Klaviyo.initialize("xxxxx", applicationContext)

The Klaviyo Android SDK version information

2.4.0

Device Information

Galaxy s21

Android Studio Version

2023.3.1 Patch 1

Android API Level

34

HuangBiaoHb commented 2 months ago

微信图片_20240828170323

HuangBiaoHb commented 2 months ago

It should be the kotlin version that causes the crash

jordan-griffin commented 2 months ago

Hey, looks like your Kotlin version is outdated. Can you try switching to Kotlin stdlib 1.9.22? That would match the Kotlin version we use in our SDK. If you are trying to compile on as low a version of Kotlin as possible, I believe Kotlin version 1.8.20 is where the EnumEntries class was introduced.

dan-peluso commented 2 months ago

@HuangBiaoHb thanks for filing! I think we'll definitely add the Kotlin version that we depend on in our docs, but I am curious if there is something else going on here. I tried replicating this with your specified Kotlin and Gradle versions, but I was actually unable to compile in those cases, getting something like this for my references: Class 'com.klaviyo.analytics.Klaviyo' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1. Can you confirm those versions as well as the Android Gradle Plugin version and Core ktx version?

HuangBiaoHb commented 2 months ago

Thank you. It seems that our project has specified the kotlin version, and there was a problem of too many versions reporting errors

HuangBiaoHb commented 2 months ago

I will try to upgrade the kotlin version

dan-peluso commented 2 months ago

https://github.com/klaviyo/klaviyo-android-sdk/pull/183