aws-geospatial / amazon-location-mobile-auth-sdk-android

Apache License 2.0
3 stars 4 forks source link

Support aws-sdk-kotlin / smithy-kotlin's `OkHttp4Engine` #17

Open lauzadis opened 1 day ago

lauzadis commented 1 day ago

Hello, I am from the AWS SDK for Kotlin team. We have a customer trying to use this project and running into issues with their OkHttp configuration.

We offer an OkHttp4 engine for users that can't rely on the default engine which uses OkHttp5, an alpha version. The customer configured their project to use this OkHttp4Engine, but your project creates its own Kotlin SDK clients which still use OkHttp5, causing conflicts for the customer.

Are you able to provide some configuration options for users who want to use the OkHttp4Engine? One way this could be done is by accepting a custom Kotlin SDK as an optional parameter wherever it's used. Another option is to configure your own Kotlin SDK clients to use the OkHttp4Engine, since I noticed this project uses OkHttp 4.12.0.

cgalvan commented 1 day ago

Hello @lauzadis ,

Thanks for reaching out! We actually made a change recently that modifies the API to to return the client configuration instead of a client, which should allow your customer to create their own client and then just use our authentication SDK to provide the proper cognito configuration for the client.

I can reply directly on that linked issue, and I'll keep this issue open until that one is resolved.

drayan85 commented 1 day ago

@cgalvan , I have tried as you suggested above and still I am getting error. You can find the sample repository in the following URL (https://github.com/drayan85/AWS-Location-Demo). Please change the values for AWS_COGNITO_POOL_ID & AWS_PLACE_INDEX

If you want to reproduce by yourself.

Process: com.aws.demo, PID: 18654
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/coroutines/ExecuteAsyncKt;
    at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpEngine.roundTrip(OkHttpEngine.kt:56)
    at aws.smithy.kotlin.runtime.http.engine.internal.ManagedHttpClientEngine.roundTrip(Unknown Source:2)
    at aws.smithy.kotlin.runtime.http.SdkHttpClient$executeWithCallContext$2.invokeSuspend(SdkHttpClient.kt:44)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:101)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:589)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:832)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:720)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:707)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@d5b34a2, Dispatchers.Main.immediate]
Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.coroutines.ExecuteAsyncKt" on path: DexPathList[[dex file "/data/data/com.aws.demo/code_cache/.overlay/base.apk/classes3.dex", dex file "/data/data/com.aws.demo/code_cache/.overlay/base.apk/classes5.dex", zip file "/data/app/~~lOQBgcnKMDcsrlS4c8qxBg==/com.aws.demo-Rr7zKExyvJ5wJD0SAGj7Ug==/base.apk"],nativeLibraryDirectories=[/data/app/~~lOQBgcnKMDcsrlS4c8qxBg==/com.aws.demo-Rr7zKExyvJ5wJD0SAGj7Ug==/lib/arm64, /system/lib64, /system_ext/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:573)