exponea / exponea-android-sdk

MIT License
17 stars 16 forks source link

In App message crashes with okhttp logging library #54

Closed janwelocampo closed 1 year ago

janwelocampo commented 1 year ago

FATAL EXCEPTION: OkHttp Dispatcher java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Util; at com.exponea.sdk.util.HtmlNormalizer.asBase64Image(HtmlNormalizer.kt:245) at com.exponea.sdk.util.HtmlNormalizer.makeImagesToBeOffline(HtmlNormalizer.kt:226) at com.exponea.sdk.util.HtmlNormalizer.normalize(HtmlNormalizer.kt:81) at com.exponea.sdk.manager.InAppMessageManagerImpl.show(InAppMessageManagerImpl.kt:302) at com.exponea.sdk.manager.InAppMessageManagerImpl.showPendingMessage(InAppMessageManagerImpl.kt:211) at com.exponea.sdk.manager.InAppMessageManagerImpl.access$showPendingMessage(InAppMessageManagerImpl.kt:45) at com.exponea.sdk.manager.InAppMessageManagerImpl$preloadImageAndShowPending$1$4.invoke(InAppMessageManagerImpl.kt:135) at com.exponea.sdk.manager.InAppMessageManagerImpl$preloadImageAndShowPending$1$4.invoke(InAppMessageManagerImpl.kt:133) at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl$preload$perImageCallback$1.invoke(InAppMessageBitmapCacheImpl.kt:61) at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl$preload$perImageCallback$1.invoke(InAppMessageBitmapCacheImpl.kt:58) at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl$downloadImage$1.onResponse(InAppMessageBitmapCacheImpl.kt:97) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:535) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637) at java.lang.Thread.run(Thread.java:1012) Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.Util" on path: DexPathList[[...///]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.exponea.sdk.util.HtmlNormalizer.asBase64Image(HtmlNormalizer.kt:245)  at com.exponea.sdk.util.HtmlNormalizer.makeImagesToBeOffline(HtmlNormalizer.kt:226)  at com.exponea.sdk.util.HtmlNormalizer.normalize(HtmlNormalizer.kt:81)  at com.exponea.sdk.manager.InAppMessageManagerImpl.show(InAppMessageManagerImpl.kt:302)  at com.exponea.sdk.manager.InAppMessageManagerImpl.showPendingMessage(InAppMessageManagerImpl.kt:211)  at com.exponea.sdk.manager.InAppMessageManagerImpl.access$showPendingMessage(InAppMessageManagerImpl.kt:45)  at com.exponea.sdk.manager.InAppMessageManagerImpl$preloadImageAndShowPending$1$4.invoke(InAppMessageManagerImpl.kt:135)  at com.exponea.sdk.manager.InAppMessageManagerImpl$preloadImageAndShowPending$1$4.invoke(InAppMessageManagerImpl.kt:133)  at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl$preload$perImageCallback$1.invoke(InAppMessageBitmapCacheImpl.kt:61)  at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl$preload$perImageCallback$1.invoke(InAppMessageBitmapCacheImpl.kt:58)  at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl$downloadImage$1.onResponse(InAppMessageBitmapCacheImpl.kt:97)  at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:535)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)  at java.lang.Thread.run(Thread.java:1012) 

This happens when I try to add com.squareup.okhttp3:logging-interceptor on my gradle
I tried updating my okhttp3 also to implementation "com.squareup.okhttp3:logging-interceptor:4.10.0" (stable one)

but that issue still occurs

adam1929 commented 1 year ago

Hi @janwelocampo Please run ./gradlew app:dependencies to see which version of 'okhttp' you have. SDK contains dependency: implementation 'com.squareup.okhttp3:okhttp:4.9.3' also implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' but this lib has no reason to be part of issue. I checked content of 'okhttp' lib and I see Util.class there.

janwelocampo commented 1 year ago

@adam1929 Please see this issue

If no okhttp version is specified, currently 5.0.0-alpha.x is used. okhttp3.internal.Util class seems to have been moved to package level constants/functions in 5.0.0-alpha.x.

Please see https://github.com/square/okhttp/blob/parent-5.0.0-alpha.10/okhttp/src/commonMain/kotlin/okhttp3/internal/-UtilCommon.kt

are we going to support alpha release?

For now, what I did was adding a configuration in gradle file so that all other libraries will be forced to use this version

configurations.all { resolutionStrategy { force "com.squareup.okhttp3:okhttp:$libVersion.okhttp3" force "com.squareup.okhttp3:logging-interceptor:$libVersion.okhttp3" } }

and set it on 4.10.0

adam1929 commented 1 year ago

Hi @janwelocampo so I hope you force okhttp 4.10.0 as solution. We are not going to support alpha release of okhttp for some reasons. Anyway a good question is if we are gooing to support okhttp v 5+ (because there is great chance that stable release will be 95% same as alpha). Answer is that we have no plan to do so, for now. We have to wait until stable release and than we should look at it and do changes to support both versions.