okta / samples-android

samples-android
https://github.com/okta/samples-android
Apache License 2.0
37 stars 52 forks source link

Getting IllegalStateException for OkHttp3 while building AuthClient #76

Closed Naimish-Heritage closed 2 years ago

Naimish-Heritage commented 2 years ago

Hi, I'm following the sample codebase - sign-in-kotlin to implement custom signin with SDK approach.

In our project we've, compileSdkVersion = 30 minSdkVersion = 23 targetSdkVersion = 30

So I created a one poc project from scratch with similar SDK versions. But when I run the app I get IllegalStateException as shown in below screenshot. It seems like it's related to Okhttp library (implementation 'com.okta.sdk:okta-sdk-okhttp:6.0.0'). However when I tried decreasing compileSdkVersion & targetSdkVersion to 29, it worked!! It's bit odd that it is working for Sdkversion 29 & not for 30 or 31 (I also tested pointing to 31 but it's not working either). 2021-11-29 08_37_51-Logcat

This is what I've implemented in my app level gradle file, 2021-11-29 08_39_25-LoginWithOkta – build gradle (_app)

I'm getting exception with this build config, 2021-11-29 08_38_22-LoginWithOkta – build gradle (_app)

It's working fine with this build config, 2021-11-29 08_53_16-LoginWithOkta – build gradle (_app)

I would really appreciate if you can have a look at this issue & help me resolve it?

Thanks, Naimish

JayNewstrom commented 2 years ago

Hi @Naimish-Heritage could you please confirm you've added the coreLibraryDesugaring bits?

See: https://github.com/okta/samples-android/blob/master/sign-in-kotlin/app/build.gradle#L33-L46

Naimish-Heritage commented 2 years ago

Hi @JayNewstrom,

I had implemented coreLibraryDesugaring in the dependency list, but it wasn't enabled in the compile options so I enabled it and tried again but it didn't work. I'm getting the same exception.

image

Just to double check, I also tried simply updating compileSdkVersion & targetSdkVersion to 30 in sign-in-kotlin sample project it self and getting same exception in that as well.

Thanks, Naimish

JayNewstrom commented 2 years ago

Looks like you just need to add a dependency on the latest OkHttp.

implementation 'com.squareup.okhttp3:okhttp:4.9.3'

I'll ping our java SDK maintainer to see if we can get that updated as a transitive dependency.

JayNewstrom commented 2 years ago

Arvind is working on the final fix in the SDK. See https://github.com/okta/okta-commons-java/pull/65

Closing for now. Feel free to ping me or reopen if this doesn't fix it for you.

Naimish-Heritage commented 2 years ago

Thanks @JayNewstrom. It is working with direct okhttp reference.