Home > Net >  android: exported needs to be explicitly specified for element <service#io.intercom.android.sdk.f
android: exported needs to be explicitly specified for element <service#io.intercom.android.sdk.f

Time:06-10

I'm getting a Flutter build error in AndroidManifest.xml

android:exported needs to be explicitly specified for element <service#io.intercom.android.sdk.fcm.IntercomFcmMessengerService>. 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

There is no element called intercom in the AndroidManifest.xml file. I also added android:exported="true" in activity ".MainActivity" but the error still persists.

My AndoidManifest.xml file is as follows

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="social.myproject.app">

    <!-- The INTERNET permission is required for development. Specifically,
         flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <uses-feature
            android:name="android.hardware.camera"
            android:required="false"/>
    <uses-feature
            android:name="android.hardware.camera.autofocus"
            android:required="false" />

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https"/>

        </intent>
        <intent>
            <action android:name="com.google.android.youtube.api.service.START" />
        </intent>
    </queries>

    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
            android:requestLegacyExternalStorage="true"
            android:label="myproject"
            android:icon="@mipmap/ic_launcher"
            android:usesCleartextTraffic="true"
        >
        <meta-data
                android:name="flutterEmbedding"
                android:value="2" />
        <activity
                android:name=".MainActivity"
                android:launchMode="singleTop"
                android:theme="@style/LaunchTheme"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
                android:hardwareAccelerated="true"
                android:exported="true"
                android:windowSoftInputMode="adjustResize">
            <!-- Specify that the launch screen should continue being displayed -->
            <!-- until Flutter renders its first frame. -->
            <meta-data
                    android:name="io.flutter.embedding.android.SplashScreenDrawable"
                    android:resource="@drawable/launch_background" />

            <!-- Theme to apply as soon as Flutter begins rendering frames -->
            <meta-data
                    android:name="io.flutter.embedding.android.NormalTheme"
                    android:resource="@style/NormalTheme"
            />
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data
                        android:scheme="https"
                        android:host="www.myproject.social"
                        android:pathPrefix="/api/auth/"/>
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data
                        android:scheme="https"
                        android:host="www.myproject.io"
                        android:pathPrefix="/api/auth/"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="image/*"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="text/*"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="video/*"/>
            </intent-filter>
        </activity>
        <activity
                android:name="com.yalantis.ucrop.UCropActivity"
                android:screenOrientation="portrait"
                android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
    </application>
</manifest>

The detailed error trace :

 See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
[    1 ms] E:\App Development\MyApp - Changes\android\app\src\main\AndroidManifest.xml:11:9-16:19 Error:
[        ]      android:exported needs to be explicitly specified for element <service#io.intercom.android.sdk.fcm.IntercomFcmMessengerService>. 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



The error trace points to the following lines : 

 <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <uses-feature
            android:name="android.hardware.camera"
            android:required="true"/>
    <uses-feature
            android:name="android.hardware.camera.autofocus"
            android:required="false"/>

CodePudding user response:

This happens sometimes even if we add android exported. A workaround will be to set the targetSdkVersion to 31 and compileSDKVersion to 31 in android->app->build.gradle file

CodePudding user response:

Possibilities:

  • Have you tried to do "Invalidate/Cache and Restart"?

  • Have you tried to open the Project with the Android folder? It would display the errors if you missed anything in AndroidManifest.xml.

  • You can also try with flutter clean & flutter pub get to run again.

EDITED:

You have added some libraries and they haven't updated this service IntercomFcmMessengerService with exported = true/false

That's the reason why you are getting problems. You can do one thing that defines that service in your <application> tag with exported=true. It will override that service.

Might be that will work for you.

Hope it will help you.

  • Related