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
85 stars 99 forks source link

Get MissingForegroundServiceTypeException when connecting a vpn service #107

Open Leyfear opened 5 months ago

Leyfear commented 5 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 5 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 5 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 4 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 4 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