I did not find any example of how to replace the deprecation method. The examples on the okhttp3 main page are old. This is one of them:
public static final
You need to import these files manually may be this is a bug in android studio. It is not suggested but this is work for Okhttp 4.2.2
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.asRequestBody
and use as
val file = File("path")
file.asRequestBody("image/jpeg".toMediaTypeOrNull())