wingify / vwo-android

VWO Android SDK
https://developers.vwo.com/reference#android-introduction
MIT License
9 stars 6 forks source link

Not working with okhttp 3.12.8 and hence not working with android lower than 21 #23

Closed abhishekgargx closed 2 years ago

abhishekgargx commented 2 years ago

To support lower android version < 21, we required to use okhttp version 3.12.X

when we using this version of okhttp as mentioned above with yourvwo version : 2.8.0

code snippet

 implementation("com.squareup.okhttp3:okhttp:3.12.8") {
        force = true
    }

   implementation 'com.vwo:mobile:2.8.0@aar'
    implementation ('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    // Skip this if you are already including support library in your app.
    implementation 'com.android.support:support-core-utils:28.0.0'

we are getting this error

E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.example.app, PID: 24337
    java.lang.ClassCastException: com.newrelic.agent.android.instrumentation.okhttp3.CallExtension cannot be cast to okhttp3.RealCall
        at okhttp3.OkHttpClient$1.streamAllocation(OkHttpClient.java:188)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:204)
        at com.newrelic.agent.android.instrumentation.okhttp3.CallbackExtension.onResponse(CallbackExtension.java:42)
        at com.google.firebase.perf.network.zzf.onResponse(com.google.firebase:firebase-perf@@19.0.5:22)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)

Now if you use latest version of okhttp which 4.x.x for eg. 4.9.0. there is no error.

But as your readme file , you library support Android 4.0 (API 14) or later

abhishekgargx commented 2 years ago

@softvar @ankneo @sparshgupta @chinchang @paraschopra Hey if anyone of you knew anything about this , please do let me know.

softvar commented 2 years ago

Hey @abhishekgargx , We'll get this checked and will let you know once we have any updates. Thanks for reporting this.

abhishekgargx commented 2 years ago

hey @softvar so i found solution to fix this while looking into your code, so basically if we want to use

okhttp version 3.12.X

while your library com.vwo:mobile:2.8.0@aar

we need to set socket.io version to io.socket:socket.io-client:2.0.1 instead of version 1.0.0

Hope this finding help someone else, and they will be not force to moved to min sdk 21 , as we are about to.

softvar commented 2 years ago

Thanks, @abhishekgargx for letting us know. Glad you were able to make it work.