From 3ffb2e8e05af60a2c71c4b2e9ae078f1452eab6a Mon Sep 17 00:00:00 2001 From: Rurirei <72071920+rurirei@users.noreply.github.com> Date: Sat, 3 Oct 2020 20:23:43 +0800 Subject: [PATCH] catch exception for lateinit PropertyNotInitialized exception needs catch for lateinit var --- .../main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt index e64176aa..0e803c85 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayVpnService.kt @@ -163,7 +163,13 @@ class V2RayVpnService : VpnService(), ServiceControl { } // Create a new interface using the builder and save the parameters. - mInterface = builder.establish() + try { + mInterface = builder.establish()!! + } catch (e: Exception) { + // non-nullable lateinit var + e.printStackTrace() + stopV2Ray() + } } private fun sendFd() {