I'm updating some previously working code which uses the OkHttpUtils2 library.
The code needs to be compatible with android api levels 19, 23 and 28.
Since the code was last compiled there has been an update to the native java OkHttp library and android api level 19 is no longer supported.
On an api 19 device I now see the error:
I tried switching from OkHttpUtils2 to the older HttpUtils2 library.
This works on api 19 and api 23 but not on api 28 where I see the error:
I thought I'd detect the device api level at runtime.
If it's api 19 then use the 'low level' HttpClient and HttpRequest libraries.
If it's greater than 19 then use the OkHttpUtils2 library.
This is a non starter as it fails to compile with the error:
Looks like I could download a version of the native java OkHttp from before when they dropped support for api 19.
And replace the built in native java OkHttp library with the old version.
But I'm reluctant to do this as it'll surely create problems at a later date - when I next update b4a for example and have to remember to manually replace the latest OkHttp with an old version.
Am I missing something obvious here?
Can b4a no longer create apps which can make HTTP requests and are compatible with android api levels 19 and later?
The code needs to be compatible with android api levels 19, 23 and 28.
Since the code was last compiled there has been an update to the native java OkHttp library and android api level 19 is no longer supported.
On an api 19 device I now see the error:
On an api 23 device the code works fine, and on an api 28 device the code works fine.Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19
at okhttp3.internal.platform.AndroidPlatform.<clinit>(AndroidPlatform.kt:153
I tried switching from OkHttpUtils2 to the older HttpUtils2 library.
This works on api 19 and api 23 but not on api 28 where I see the error:
In api 28 (or some earlier version) Google have removed the old Http library.Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.methods.HttpGet" on path
I thought I'd detect the device api level at runtime.
If it's api 19 then use the 'low level' HttpClient and HttpRequest libraries.
If it's greater than 19 then use the OkHttpUtils2 library.
This is a non starter as it fails to compile with the error:
Seems like I'd have to compile with android.jar api level 21 or older to enable this to compile.src\mypackagename\httptest\main.java:535: error: cannot access ClientProtocolException
_httpclient1.Initialize("HttpClient1");
^
class file for org.apache.http.client.ClientProtocolException not found
Looks like I could download a version of the native java OkHttp from before when they dropped support for api 19.
And replace the built in native java OkHttp library with the old version.
But I'm reluctant to do this as it'll surely create problems at a later date - when I next update b4a for example and have to remember to manually replace the latest OkHttp with an old version.
Am I missing something obvious here?
Can b4a no longer create apps which can make HTTP requests and are compatible with android api levels 19 and later?