exponea / exponea-android-sdk

MIT License
17 stars 16 forks source link

Exponea Safe Mode wrapper caught unhandled error java.lang.NoSuchMethodError #73

Closed jaroslavhavelik closed 3 months ago

jaroslavhavelik commented 3 months ago

In one of our client apps we are facing following issue while initializing your SDK:

Version of SDK: 3.15.0 We are also using coil in our application, if that can be factor.

java.lang.NoSuchMethodError: No direct method <init>(Landroid/content/Context;)V in class Lcoil/decode/ImageDecoderDecoder; or its super classes (declaration of 'coil.decode.ImageDecoderDecoder' appears in /data/app/~~HvbWFIug1piX-p7X_1PR5g==/xx.xxxx.xxxxx-hMitmv_c8D15lLQeA7CLJQ==/base.apk!classes3.dex) at com.exponea.sdk.repository.SimpleDrawableCache.<init>(SimpleDrawableCache.kt:27) at com.exponea.sdk.repository.InAppMessageBitmapCacheImpl.<init>(InAppMessageBitmapCacheImpl.kt:7) at com.exponea.sdk.ExponeaComponent.<init>(ExponeaComponent.kt:141) at com.exponea.sdk.Exponea.initializeSdk(Exponea.kt:756)

adam1929 commented 3 months ago

Hi @jaroslavhavelik thank you for report. Yes, these error almost always lead to some library version mismatch. Unfortunatelly there is no easy workaround for this. Please check your ./gradlew app:dependencies tree and see which library versions are mismatched and share findings with us. Harder but possible way to fix this is repackaging of libraries. I assume that you are familiar with gradle dependency management (libraries with same package -> latest version is used by default). Also I assume that you are familiar with Java Class loader (classes are loaded by class full name). Therefore you need to let SDK use coil.decode.ImageDecoderDecoder class of version 1.4.0. Then you need to tell you app to use coil.decode.ImageDecoderDecoder class of later version (defined by you). To achieve that, possible solution is repackage your coil library to repackaged.coil.decode.ImageDecoderDecoder, so 2 classes could exists under same project. https://github.com/Tinkoff/gradle-jarjar It is unfortunate that coil library has not 100% backward compatibility to itself between versions, but this is a common problem for all libraries and opposite reality is utopia :-/

jaroslavhavelik commented 3 months ago

HI @adam1929,

thanks for a quick reply. Here is dependencies that are mismatched between yours and our side (truncated output)

| | | +--- com.exponea.sdk:sdk:3.15.0 | | | | +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.7.20 -> 2.0.0 () | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20 -> 1.9.20 () | | | | +--- androidx.room:room-runtime:2.1.0 -> 2.6.1 () | | | | +--- io.github.pilgr:paperdb:2.7.1 | | | | | +--- com.esotericsoftware:kryo:4.0.1 | | | | | | +--- com.esotericsoftware:reflectasm:1.11.3 | | | | | | | --- org.ow2.asm:asm:5.0.4 | | | | | | +--- com.esotericsoftware:minlog:1.3.0 | | | | | | --- org.objenesis:objenesis:2.5.1 | | | | | --- de.javakaffee:kryo-serializers:0.40 | | | | | --- com.esotericsoftware:kryo:4.0.0 -> 4.0.1 () | | | | +--- com.squareup.okhttp3:okhttp:4.9.3 -> 4.12.0 () | | | | +--- com.google.code.gson:gson:2.10.1 | | | | +--- org.danilopianini:gson-extras:0.2.2 | | | | | +--- com.google.code.gson:gson:2.8.6 -> 2.10.1 | | | | | --- javax.annotation:jsr250-api:1.0 | | | | +--- com.squareup.okhttp3:logging-interceptor:4.9.3 -> 4.11.0 | | | | | +--- com.squareup.okhttp3:okhttp:4.11.0 -> 4.12.0 () | | | | | --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.9.20 () | | | | +--- androidx.work:work-runtime-ktx:2.7.1 | | | | | +--- androidx.work:work-runtime:2.7.1 | | | | | | +--- androidx.annotation:annotation-experimental:1.0.0 -> 1.4.0 () | | | | | | +--- com.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava | | | | | | +--- androidx.lifecycle:lifecycle-livedata:2.1.0 -> 2.7.0 () | | | | | | +--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1 () | | | | | | +--- androidx.core:core:1.6.0 -> 1.13.1 () | | | | | | +--- androidx.room:room-runtime:2.2.5 -> 2.6.1 () | | | | | | +--- androidx.sqlite:sqlite:2.1.0 -> 2.4.0 () | | | | | | +--- androidx.sqlite:sqlite-framework:2.1.0 -> 2.4.0 () | | | | | | +--- androidx.core:core:1.1.0 -> 1.13.1 () | | | | | | --- androidx.lifecycle:lifecycle-service:2.1.0 -> 2.7.0 () | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.5.30 -> 2.0.0 () | | | | | --- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0 -> 1.8.1 () | | | | +--- androidx.constraintlayout:constraintlayout:2.0.4 -> 2.1.4 () | | | | +--- com.google.android.material:material:1.2.1 -> 1.12.0 () | | | | +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0 -> 2.7.0 () | | | | +--- com.squareup.okhttp3:okhttp-brotli:4.9.1 -> 4.11.0 | | | | | +--- com.squareup.okhttp3:okhttp:4.11.0 -> 4.12.0 () | | | | | +--- org.brotli:dec:0.1.2 | | | | | --- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.9.20 () | | | | +--- org.jsoup:jsoup:1.15.4 -> 1.17.2 | | | | +--- io.coil-kt:coil:1.4.0 -> 2.6.0 () | | | | +--- io.coil-kt:coil-gif:1.4.0 -> 2.6.0 | | | | | +--- androidx.core:core-ktx:1.12.0 -> 1.13.1 () | | | | | +--- androidx.vectordrawable:vectordrawable-animated:1.1.0 () | | | | | +--- io.coil-kt:coil-base:2.6.0 () | | | | | --- org.jetbrains.kotlin:kotlin-stdlib:1.9.22 -> 2.0.0 () | | | | --- androidx.browser:browser:1.5.0 (*)

It makes complete sense that coil (or any other library) is not backwards compatible across major releases. The real question is, whats your reason to use almost 3 years old (coil 1.4.0 was released on 6th October 2021) version of Coil. Coil 2.0.0 was released on 10th of May 2022, that gives you more than 2 years to adopt to v2.

Edit: Not sure why you marked the issue as completed - it is obviously an issue that should be resolved. And as you proposed if you intend to use coil that is 3 years old, IMHO you should be the ones to do the repackaging of Coil library

obraz commented 3 months ago

I also got this crash in the new version 3.15.0. Please fix it

shanio commented 2 months ago

@adam1929 Can you please revisit this issue and consider updating the library on your end?

The biggest concern here is that we all need to coexist in this ecosystem. One or more of libraries that do not update their dependencies without library cause huge issues to all of the clients. We need to update the coil to stay compatible with androidx, compose, kotlin and other stuff. This time it is limited to coil, what will be the next thing?

By not updating it and forcing the clients to shadow a dependency is just disrespectful, and is similar to taking the client apps a hostage by using and outdated and incompatible version of a library. Your decision will not only complicate the situation to all of the users of your library (instead of just one library dev), but also unnecessarily increase the size of the app for the users.

If for some reason dependency shadowing is a must, the library is usually the one to do when it for some specific reason can not stick with the latest version as it is in this case. If that issue would be on application side, for sure the team would be required to do some actions and it will not be the responsibility of the library.

xcibik00 commented 2 months ago

Hi @jaroslavhavelik , @obraz and @shanio ,

Apologize for later reply. We understand your situation. Current setup has some + and -, and all other setups will have too.

Please reach out your Bloomreach CSM to be able to discuss possible solutions also with product to be able to resolve your issues. Thanks!

obraz commented 2 months ago

Do you want all users of your library to perform a lot of magic instead of you upgrading the version of Coil once or doing a repackage if necessary?

matejsemancik commented 2 months ago

Hey, just stumbled upon this issue, as I'm in the same situation. Gonna throw in my two cents -- I believe this should be fixed on Exponea side for reasons mentioned above. I'm just another user needing to integrate this SDK into our app and this is blocker for us, and IMHO suggested solution is an ugly workaround.

adam1929 commented 2 months ago

Hi all, we truly share your thinking. We are investigating solutions for this problem because updating of Coil library will affect other libraries, will affect minSdkVersion and affects range of target customers. Thank you for your patience.

adam1929 commented 2 months ago

Hi guys, please contact your CSM via support channel to investigate this issue deeply and define next steps more effectively. Thank you