Nativescript 崩溃 "Expected Android API level 21+ but was 30"

Nativescript crashes "Expected Android API level 21+ but was 30"

我的应用程序在我的真实设备和模拟器(Android 10 - API 29)上完美启动,但是当我尝试在 Android 11 - api 30,启动画面后崩溃并出现此错误:

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.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.run(Socket.java:142)
    at io.socket.thread.EventThread.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

我发现 this article 说你必须更新 okhttp3 但我不知道如何在 nativescript 中执行此操作,我猜它在 nativescript/core ?

我的环境:

感谢大家的帮助

这已在 3.12.13(旧版 Android)、3.14.7(Android 5+)和 4.9.1 中的 OkHttp https://github.com/square/okhttp/issues/6569 中修复 https://github.com/square/okhttp/blob/edf477cb4e7b1d59c6e3e5ac00870619340ce990/docs/changelog_3x.md#version-3147

有关更新依赖项的讨论和示例,请参阅 https://github.com/NativeScript/canvas/issues/32