I am using FCM notification and I have set the following in my AndroidManifest.xml:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/splash" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming notification message. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/splash_color" />
where splash is a transparent png image.
I also have the android app icon which I am setting like this in the same manifest file:
<application
android:name="io.flutter.app.FlutterApplication"
android:label="myapp"
android:icon="#drawable/ic_launcher">
What happens is that when a notification pops up, it picks up the ic_launcher instead of splash. If I replace ic_launcher and keep splash as my android icon, then I see the notification icon.
However, if I do it this way, then my app icon (which is now a transparent image) get's a black color as background which I don't want. I want the ic_launcher to be my background color. I fail to understand as to why the image defined at android:icon gets picked up for notification ?
For anyone struggling with this, please put the meta-tags right after the application tag. Do not put them under the activity tag. So something like this:
<application
android:name="io.flutter.app.FlutterApplication"
android:label="When Coin"
android:icon="#mipmap/ic_launcher">
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#mipmap/ic_notification" />
<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:windowSoftInputMode="adjustResize">
<!-- This keeps the window background of the activity showing
until Flutter renders its first frame. It can be removed if
there is no splash screen (such as the default splash screen
defined in #style/LaunchTheme). -->
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
Related
In our app we have several launcher icons. We do it via activity-alias. Code in Manifest looks like below. The problem is that I can't show different splash screen logos. Splash screen style is used only from <activity> tag. The one in <activity-alias> tag is ignored.
<activity
android:name=".modules.launcher.LauncherActivity"
android:theme="#style/Theme.App.MainLauncherStyle" />
<activity-alias
android:name="${applicationId}.MainLauncherAlias"
android:enabled="true"
android:icon="#mipmap/launcher_main"
android:label="#string/App_Name"
android:exported="true"
android:theme="#style/Theme.App.MainLauncherStyle"
android:targetActivity=".modules.launcher.LauncherActivity">
</activity-alias>
<activity-alias
android:name="${applicationId}.DarkLauncherAlias"
android:enabled="false"
android:icon="#mipmap/launcher_dark"
android:label="#string/App_Name"
android:exported="true"
android:theme="#style/Theme.App.DarkLauncherStyle"
android:targetActivity=".modules.launcher.LauncherActivity">
</activity-alias>
I am developing Flutter on Vs Code,
This is my AndroidManifest.xml files and I get this error :Please ensure that the android manifest is a valid XML document and try again
I think I have a double quotes or other problem,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.object_detection">
<!-- 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:name="io.flutter.app.FlutterApplication"
android:label="Object Detector"
android:icon="#mipmap/launcher_icon">
<meta-data android:name="com.google.android.gms.ads.APPLICATIN_ID" android:value
<activity
android:name=".MainActivity"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
You are have a android:value that is not in parameter. This is corrected Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.object_detection">
<!-- 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:name="io.flutter.app.FlutterApplication"
android:label="Object Detector"
android:icon="#mipmap/launcher_icon">
<meta-data android:name="com.google.android.gms.ads.APPLICATIN_ID"
<activity
android:name=".MainActivity"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
I wrote a simple app in flutter and then after some research I changed the name and icon. After changing these two I got errors which I never had before on AndroidManifest.xml. I tried few things after research on thew Net. (like invalidate cache and restart) but still I get those errors. I would appreciate every help.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.sarisayfav1"
android:versionCode="TODO"
android:versionName="TODO">
<!-- 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:name="io.flutter.app.FlutterApplication"
android:label="Akçakale_Sarı_Sayfa"
android:icon="#android:mipmap/sym_def_app_icon"
tools:ignore="NewApi">
<activity
android:name=".MainActivity"
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"
tools:targetApi="honeycomb">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
android:versionCode="TODO"
android:versionName="TODO"
remove these 2 lines.
TODO is not a recognized android version Name. flutter will set them automatically
I got suddenly 14 errors when I clicked to AndroidManifest.xml in the src/main. I was trying to add admob by following instructions but I messed up. I don't know what to do. I integrated firebase and it was fine until adding admob. The instructions are not clear on the web site. Please someone show me what is wrong step by step.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Akcakale_Sari_Sayfa">
<!-- 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:name="io.flutter.app.FlutterApplication"
android:label="Akcakale_Sari_Sayfa"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
<manifest>
<application>
<!-- Sample AdMob app ID: ca-app-pub-************************ -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-**************************"/>
</application>
</manifest>
You added an extra < application> and < manifest> tag.
Paste the admob meta tags inside the above < application> tag.
Delete extra tags.
Like this;
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Akcakale_Sari_Sayfa">
<!-- 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:name="io.flutter.app.FlutterApplication"
android:label="Akcakale_Sari_Sayfa"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
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">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<!-- Sample AdMob app ID: ca-app-pub-************************ -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-**************************"/>
</application></manifest>
I'm new with FCM. I cannot make FCM use my app icon as notification icon and the icon is always a white blank one.
I imported an icon to mipmap folders but nothing seems changed. As some dude say that this is because of lollipop notification as in this question
But the problem is, the FCM notification automatically pops up and I cannot get the Notification builder to override the icon. How can I change it?
This is the default behaviour of FCM. When app is in background it will take white icon.
Use this tag and put it in your Manifest. For me this worked. Hope it works for you too. Ensure meta-data is inside application like the example mentioned in quickstart
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<!-- [START fcm_default_icon] -->
<!-- Set custom default icon. This is used when no icon is set for incoming notification messages. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_ic_notification" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorAccent" />
<!-- [END fcm_default_icon] -->
<!-- [START fcm_default_channel] -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="#string/default_notification_channel_id" />
<!-- [END fcm_default_channel] -->
<activity
android:name=".EntryChoiceActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".kotlin.MainActivity" />
<activity android:name=".java.MainActivity" />
If you are having this problem
See this link: Icon not displaying in notification: white square shown instead
I had the same problem. I solved by making transparent image from designer.
Make sure your logo should be 72*72 pixels.
NOTE: Don't time waste in googling this issue, you just need a transparent icon which should be 72*72 dimensions.
The only thing that worked for me was to generate a Notification icon image asset in Android studio.
To use the an image as the notification icon, just set Asset type to "Image" and select the file.
Tip #1: use an icon which is of white color, on transparent background!
Tip #2: if the preview on the right side of the window contains only white squares, your notification icon will look just like that - white squares!
Tip #3: the Name of the asset is what should be added into the meta-data tag in AndroidManifest
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/whatever_you_set_for_image_asset_name" />
Source: Taken from this answer
Keep your notification small as 72 x 72 and make it completely white. See the photo attached with this answer.
Then paste the codes below into your manifest.
<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_money" />
You can make a new icon from default icons pack of Android Studio.
For this right click on your drawable folder > New > Image Asset
I faced same problem and did everything suggested here and nothing worked.
Eventually, downgrading the firebase plugin from 11.8.0 to 11.6.0 resolves it with the help of this github issue.
This might also help someone.
When no icons are set for incoming notifications, firebase will take the default icon and shows notification.
To override the default icon add below code into your Android manifest file
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/ic_stat_ic_notification" />
For more information you can follow the link