Android Question erreur lors de l'éxécution du projet

YPMN

Member
Licensed User
Longtime User
Hi;

Here is my problem: for an application that works well on a tablet, it returns an error message when loading. The message that seems to pin Okhttp3.OkHttpClient ... seems incomprehensible to me. Here is the error code:

Error while loading:
PackageAdded: package:zns.gbase
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
sending message to waiting queue of uninitialized activity (submitjob)
*** Receiver (httputils2service) Receive (first time) ***
java.lang.ExceptionInInitializerError
    at okhttp3.internal.platform.Platform$Companion.findAndroidPlatform(Platform.kt:219)
    at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:212)
    at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:169)
    at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:170)
    at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:237)
    at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1069)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at zns.gbase.httputils2service._service_create(httputils2service.java:225)
    at zns.gbase.httputils2service._receiver_receive(httputils2service.java:185)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at zns.gbase.httputils2service.onReceive(httputils2service.java:42)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2602)
    at android.app.ActivityThread.access$1700(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5323)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19
    at okhttp3.internal.platform.AndroidPlatform.<clinit>(AndroidPlatform.kt:153)
    ... 30 more
java.lang.RuntimeException: Unable to start receiver zns.gbase.httputils2service: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2609)
    at android.app.ActivityThread.access$1700(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
    at android.os.Handler.dispatchMessage(Handler.java:110)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:5323)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.ExceptionInInitializerError
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:188)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at zns.gbase.httputils2service.onReceive(httputils2service.java:42)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2602)
    ... 10 more
Caused by: java.lang.ExceptionInInitializerError
    at okhttp3.internal.platform.Platform$Companion.findAndroidPlatform(Platform.kt:219)
    at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:212)
    at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:169)
    at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:170)
    at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:237)
    at okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1069)
    at anywheresoftware.b4h.okhttp.OkHttpClientWrapper.Initialize(OkHttpClientWrapper.java:94)
    at zns.gbase.httputils2service._service_create(httputils2service.java:225)
    at zns.gbase.httputils2service._receiver_receive(httputils2service.java:185)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    ... 13 more
Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19
    at okhttp3.internal.platform.AndroidPlatform.<clinit>(AndroidPlatform.kt:153)
    ... 30 more
** Activity (main) Resume **
17
libcore.io.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
17

how can I avoid this error when the same application is elsewhere?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is the relevant message: Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19

OkHttp works with Android 5+ (api 21). You are running it on an Android 4 (api 19) device.

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…