openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Duration Getting this issue in Android 7

Open softylogics opened this issue 2 years ago • 1 comments

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/Duration; at com.theokanning.openai.service.OpenAiService.(OpenAiService.java:45)

I am getting this error in android 7 as Duration class is above the API level of android 7. Is there any workaround for this?

softylogics avatar Jun 27 '23 01:06 softylogics

Can you use the other constructor? Create an ExecutorService with the timeout you want which is a long, not a Duration and then pass the executor service to the constructor.

public OpenAiService(final OpenAiApi api, final ExecutorService executorService) {

https://developer.android.com/reference/java/util/concurrent/ExecutorService

cryptoapebot avatar Jun 27 '23 02:06 cryptoapebot