Categories
discuss

Expected Android API level 21+ but was 30

How is it possible that I get this message? It does not make any sense. I’m using com.squareup.retrofit2:retrofit:2.9.0

     Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 30
    at okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported(AndroidPlatform.kt:370)
    at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:204)
    at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:178)
    2020-09-16 12:37:07.645 6480-6480/lv.ltt.gasogmp.dev_v3 E/AndroidRuntime:     at 
    okhttp3.internal.platform.Platform.<clinit>(Platform.kt:179)

Answer

Add an explicit dependency on OkHttp 4.9.0. Or whatever is newest at the time you read this.

This bug is embarrassing but it’s been fixed for so long that you shouldn’t be encountering it in new code.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..