How to fix Expected Android API level 21+ but was 19 in Android

For minSDK lower than 21, change your OkHttp version to 3.12.12 in gradle like this –

  //OkHttp
  implementation ("com.squareup.okhttp3:okhttp:3.12.12"){
      force = true //API 19 support
  }
  implementation 'com.squareup.okhttp3:logging-interceptor:3.12.12'

It should work fine!

Leave a Comment