My app launches perfectly on my real device and on emulators (both Android 10 - API 29), but when I try to emulate on a Android 11 - api 30, it crashes after splash screen with this error :
StackTrace:
java.lang.ExceptionInInitializerError
at okhttp3.internal.platform.Platform.get(Platform.java:85)
at okhttp3.OkHttpClient.newSslSocketFactory(OkHttpClient.java:263)
at okhttp3.OkHttpClient.<init>(OkHttpClient.java:229)
at okhttp3.OkHttpClient.<init>(OkHttpClient.java:202)
at io.socket.engineio.client.Socket.<init>(Socket.java:215)
at io.socket.engineio.client.Socket.<init>(Socket.java:174)
at io.socket.client.Manager$Engine.<init>(Manager.java:638)
at io.socket.client.Manager$1.run(Manager.java:277)
at io.socket.thread.EventThread.exec(EventThread.java:55)
at io.socket.client.Manager.open(Manager.java:266)
at io.socket.client.Manager.open(Manager.java:256)
at io.socket.client.Socket$3.run(Socket.java:142)
at io.socket.thread.EventThread$2.run(EventThread.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 30
at okhttp3.internal.platform.AndroidPlatform.buildIfSupported(AndroidPlatform.java:238)
at okhttp3.internal.platform.Platform.findPlatform(Platform.java:202)
at okhttp3.internal.platform.Platform.<clinit>(Platform.java:79)
... 16 more
I found this article that says you have to update okhttp3 but I don't know how to do this in nativescript, i'm guessing it's in the nativescript/core ?
My environement :
Thanks all for your help
This is fixed in OkHttp https://github.com/square/okhttp/issues/6569 in 3.12.13 (Legacy Android), 3.14.7 (Android 5+) and 4.9.1 https://github.com/square/okhttp/blob/edf477cb4e7b1d59c6e3e5ac00870619340ce990/docs/changelog_3x.md#version-3147
See https://github.com/NativeScript/canvas/issues/32 for a discussion and example of updating the dependency