nizwar / openvpn_flutter

A package that allow you to connect OpenVPN service with Flutter
https://pub.dev/packages/openvpn_flutter
GNU General Public License v3.0
83 stars 94 forks source link

Get MissingForegroundServiceTypeException when connecting a vpn service #107

Open Leyfear opened 3 months ago

Leyfear commented 3 months ago

Still same error for Android 14+ after fix PR.

Error when show notification E/de.blinkt.openvpn.core.OpenVPNService( 9598): android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{45c0324 9598:com.example.flutter_application_1/u0a425} targetSDK=34

nizwar commented 3 months ago

Can you try to add this on AndroidManifest.xml

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" android:minSdkVersion="34" />

let me know the result after

willieee802 commented 3 months ago

Can you try to add this on AndroidManifest.xml

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" android:minSdkVersion="34" />

let me know the result after

I just tried that and the error still pops.

The changes I made while using this package are:

Not sure of anything missed or put in wrong place, the app pops permissions request correctly, vpn connects just fine, but keeps poping that forground service error.

ighostnb commented 3 months ago

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="id.laskarmedia.openvpn_flutter">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" android:minSdkVersion="34" />

<application
    android:icon="@mipmap/ic_launcher">

    <service
        android:name="de.blinkt.openvpn.core.OpenVPNService"
        android:foregroundServiceType="systemExempted"
        android:exported="false"
        tools:replace="android:exported" />
</application>

change it in package manifest

willieee802 commented 3 months ago
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED" android:minSdkVersion="34" />

<application
    android:icon="@mipmap/ic_launcher">

    <service
        android:name="de.blinkt.openvpn.core.OpenVPNService"
        android:foregroundServiceType="systemExempted"
        android:exported="false"
        tools:replace="android:exported" />
</application>

change it in package manifest

Problem solved