Closed AleshaD closed 1 week ago
I am also looking for a solution to this problem. This problem only occurs in android 14 or above. In android 13 or less it works fine.
It might be a foreground/background service issue, that's my guess
Hi. This is a fix https://github.com/b4nghh/flutter_vpn/commit/7c47d67491170875f7f0b75e0213f1acaadd71d5 We will test for a few more days and if everything goes well, I will make a pool request.
@AleshaD how to upgrade in my flutter project. I am lost!!
Also the flutter_vpn package in pub.dev isn't being updated for 2years.
It looks like this plugin is no longer supported, but the pr with the fix is here, maybe they will update the thread someday...
@thecyfrin сurrently, you can fork the repository and make changes to the files yourself. In pubspec, add a link to your repository.
Like this flutter_vpn: git: url: https://github.com/YOUR_REPO/flutter_vpn ref: d47f57b6453f1003ec08ce648c59e82a3826b341
ref - hash code of the commit with the change
I have already did this configs. And working fine is Android 13 and Android 14(only emulator). But it's showing connecting in android 14 physical devices. The console log is showing the same issue:
[ +15 ms] D/AndroidRuntime(18070): Shutting down VM [ ] E/AndroidRuntime(18070): FATAL EXCEPTION: main [ [ ] E/AndroidRuntime(18070): Process: com.nshot.vpn, PID: 18070 ] E/AndroidRuntime(18070): android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{725a1d2 18070:com.nshot.vpn/u0a603} targetSDK=34 [ ] E/AndroidRuntime(18070): at android.app.MissingForegroundServiceTypeException$1.createFromParcel(Missi ngForegroundServiceTypeException.java:53) [ ] E/AndroidRuntime(18070): at android.app.MissingForegroundServiceTypeException$1.createFromParcel(Missi ngForegroundServiceTypeException.java:49) [ ] E/AndroidRuntime(18070): at android.os.Parcel.readParcelableInternal(Parcel.java:4882) [ ] E/AndroidRuntime(18070): at android.os.Parcel.readParcelable(Parcel.java:4864) [ ] E/AndroidRuntime(18070): at android.os.Parcel.createExceptionOrNull(Parcel.java:3064) [ ] E/AndroidRuntime(18070): at android.os.Parcel.createException(Parcel.java:3053) [ ] E/AndroidRuntime(18070): at android.os.Parcel.readException(Parcel.java:3036) [ ] E/AndroidRuntime(18070): at android.os.Parcel.readException(Parcel.java:2978) [ ] E/AndroidRuntime(18070): at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManag er.java:7234) [ ] E/AndroidRuntime(18070): at android.app.Service.startForeground(Service.java:775) [ ] E/AndroidRuntime(18070): at org.strongswan.android.logic.CharonVpnService$2.run(CharonVpnService.java:3 35) [ ] E/AndroidRuntime(18070): atandroid.os.Handler.handleCallback(Handler.java:958) [ ] E/AndroidRuntime(18070): at android.os.Handler.dispatchMessage(Handler.java:99) [ ] E/AndroidRuntime(18070): at android.os.Looper.loopOnce(Looper.java:230) [ ] E/AndroidRuntime(18070): at android.os.Looper.loop(Looper.java:319) [ ] E/AndroidRuntime(18070): at android.app.ActivityThread.main(ActivityThread.java:8919) [ ] E/AndroidRuntime(18070): at java.lang.reflect.Method.invoke(Native Method) [ ] E/AndroidRuntime(18070): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java: 578) [ ] E/AndroidRuntime(18070): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) [ ] I/flutter (18070): This is the state FlutterVpnState.connecting && FlutterVpnState [ +23 ms] I/charon (18070): 00[LIB] loaded plugins: androidbridge charon android-log openssl fips-prf random nonce pubkey chapoly curve25519 pkcs1 pkcs8 pem xcbc hmac socket-default revocation eap-identity eap-mschapv2 eapmd5 eap-gtc eap-tls x509 [ ] I/charon (18070): 00[JOB] spawning 16 worker threads [ [ ] I/CharonVpnService(18070): charon started ] W/ConnectionStatusConfig(18070): Dynamic lookup for intent failed for action: com.google.android.gms.ads.service.START [ +14 ms] I/charon (18070): 00[DMN] thread 1 received 11 [ +357 ms] Service protocol connection closed. [ ] Lost connection to device. [ ] DevFS: Deleting filesystem on the device (file:///data/user/0/com.nshot.vpn/code_cache/NShot%20VPNQRXILW/NShot%2 0VPN/) [ +257 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed [ +1 ms] "flutter run" took 184,148ms. [ +263 ms] ensureAnalyticsSent: 260ms
This should be fixed by #126 I will update the package on pub.dev
Description: When compiling an Android app with compileSdkVersion set to 34 and targetSdkVersion set to 34, the app crashes whenever it tries to connect to a VPN using the flutter_vpn library. This issue does not occur when the app is compiled with lower SDK versions (e.g., 33).
Steps to Reproduce:
Actual Behavior: The app crashes immediately upon attempting to connect to the VPN.
Additional Information: Lowering the SDK versions back to 33 resolves the issue, suggesting a compatibility problem with SDK 34.
Log: W/System.err( 8171): at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2743) W/System.err( 8171): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2815) W/System.err( 8171): at android.os.Binder.execTransactInternal(Binder.java:1500) D/AndroidRuntime( 8171): Shutting down VM E/AndroidRuntime( 8171): FATAL EXCEPTION: main E/AndroidRuntime( 8171): Process: com.example.sandbox, PID: 8171 E/AndroidRuntime( 8171): android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{dd1b2a5 8171:com.example.sandbox/u0a207} targetSDK=34 E/AndroidRuntime( 8171): at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53) E/AndroidRuntime( 8171): at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49) E/AndroidRuntime( 8171): at android.os.Parcel.readParcelableInternal(Parcel.java:5075) E/AndroidRuntime( 8171): at android.os.Parcel.readParcelable(Parcel.java:5057) E/AndroidRuntime( 8171): at android.os.Parcel.createExceptionOrNull(Parcel.java:3237) E/AndroidRuntime( 8171): at android.os.Parcel.createException(Parcel.java:3226) E/AndroidRuntime( 8171): at android.os.Parcel.readException(Parcel.java:3209) E/AndroidRuntime( 8171): at android.os.Parcel.readException(Parcel.java:3151) E/AndroidRuntime( 8171): at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7164) E/AndroidRuntime( 8171): at android.app.Service.startForeground(Service.java:776) E/AndroidRuntime( 8171): at org.strongswan.android.logic.CharonVpnService$2.run(CharonVpnService.java:335) E/AndroidRuntime( 8171): at android.os.Handler.handleCallback(Handler.java:959) E/AndroidRuntime( 8171): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime( 8171): at android.os.Looper.loopOnce(Looper.java:232) E/AndroidRuntime( 8171): at android.os.Looper.loop(Looper.java:317) E/AndroidRuntime( 8171): at android.app.ActivityThread.main(ActivityThread.java:8674) E/AndroidRuntime( 8171): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 8171): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) E/AndroidRuntime( 8171): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886) I/Process ( 8171): Sending signal. PID: 8171 SIG: 9 Lost connection to device.
Exited.