DolDurma
DolDurma

Reputation: 17340

Flutter fix android:exported error on android project

I used this repository on github on our project and when i try to run or getting build application I get this error:

android:exported needs to be explicitly specified for element <activity#de.blinkt.openvpn.LaunchVPN>. 
Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` 
when the corresponding component has an intent filter defined.

in that library we have this AndroidManifest.xml without android:exported element

<service
    android:name="de.blinkt.openvpn.core.OpenVPNService"
    android:permission="android.permission.BIND_VPN_SERVICE">
    <intent-filter>
        <action android:name="android.net.VpnService"/>
    </intent-filter>
</service>

<activity
    android:name="de.blinkt.openvpn.LaunchVPN"
    android:excludeFromRecents="true"
    android:label="@string/vpn_launch_title"
    android:theme="@android:style/Theme.DeviceDefault.Light.Panel">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

the library owner don't added this element on that and this library implemented by this code:

implementation 'com.github.Topfreelancerdeveloperr:flutter_openvpn_library_updated:3361996fa1'

i think i should fork this project to add this element but i don't know how can i use forked project on github in gradle

Upvotes: 1

Views: 1199

Answers (1)

Priyanka Rawat
Priyanka Rawat

Reputation: 413

Now when creating new Flutter project, a property android:exported="true" is now automatically added in AndroidManifest.xml. I faced similar issue with my one of old project during building. I just added it in <activitiy> of AndroidManifest and it worked fine.

Your <activity block should look like this.

<activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">

Upvotes: 4

Related Questions