Issue displaying flutter app icon on certain versions of android - android

I have a flutter app in which I have generated app icons for under the android folder of the project with the image asset tool that comes with android studio. On certain versions of android however neither this icon or flutter's default icon displays which seems to tell me this isn't just an issue with the icons I've provided, I instead get the default green android as such:
The screenshots above have come from an android 5 emulator (albeit quite old now its still technically supported by flutter so I wanted to test this) and I get the same problems on a physical device running android 7, but the icon seems to appear fine on any versions above. Something else I have noticed is that no app name appears in the multitasking menu but I'm not sure if that is a completely unrelated issue.
If anyone could help me that would be great, as I can't figure out what other icons I need to place in the project as I thought I'd covered all options. Thanks.
Edit- This is the android manifest for my app:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="me.letalis.testapp">
<application
android:label="Test App"
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>
Res folder:

Follow these Steps to Change/Customize Launcher Logo in Android Studio,
*Expand the project root folder in the Project View
*Right Click on the app folder
*In the Context Menu go to New->Image Asset
*In the pop up that appears select the the new logo you would like to have(image/clip art/text).
*If you were selecting the image radio button (as is the default choice), if you clicked on the 3-buttons to show the path tree to locate your .png image file, most probably you might not be seeing it, so drag it from the Windows Explorer (if Windows) and drop it in the tree, and it will appear and ready for being selected.
**Don't forget to set new icon's location in manifest: replace drawable to minimap in android:icon –
..........Mipmap Solution:
As you can see this Snapshot, I set Mipmap for every version, you can follow this also,
You have to create an XML file for anydpi-v26
`<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#color/ic_launcher_background"/>
<foreground android:drawable="#mipmap/ic_launcher_foreground"/>
</adaptive-icon>`

Related

Flutter v2.5.0 Android Splash Screen

I had implemented a native splash screen in my current project and everything was working correctly since I upgraded to v2.5.0 and I am starting to get this deprecation warning on my console:
A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
I have checked out the given link (which is not that clear btw) and tells me to remove the o.flutter.embedding.android.SplashScreenDrawable API as flutter now automatically displays the splash.
But after running my app without the code no splash screen appears moreover it takes a while to start the app - probably initializing the app without the splash or something.
Am I doing this right or is it an issue with the framework itself?
It is caused by having the following code in your AndroidManifest.xml, which was included by default in previous versions of Flutter:
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
The solution is to remove the above code.
Source
Follow this youtube tutorial on how to correctly Create Splash Screen in Flutter App the Right Way in 2021. Ensure to create the launch_background.xml file in both drawable and drawable-v21 folders inside the android/app/src/main/res folder.
Create Splash Screen in Flutter App the Right Way in 2021
If you are using Flutter 2.5, remove the following line in your AndroidManifest.xml file since Flutter 2.5 has no need for it anymore as mentioned here --> android splash migration
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"/>
Remove the below lines from your AndroidManifest.xml file. In newer versions it's no longer used
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme" />
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background" />
Here is one solution that worked in my case.
You have a "drawable" and "drawable-v21" folders on the path "android/app/src/main/res/" and you must open the "launch_background.xml" in "drawable-v21" folder, paste and a little bit refactor my code to provide your image or/and color:
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:color/your_color" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/your_image" />
</item>
</layer-list>
P.S. The image should be in "drawable" folder, not "drawable-v21". You can try, but in my case that didnt work and throw the error.
P.S.2 I didn't change the "AndroidManifest.xml", "styles.xml" and other files.

Android launcher icon only appears in the emulator

I'm trying to add a launcher icon to my android app. I have watched multiple tutorials online that explain how that works. I ended up doing it this way:
https://www.youtube.com/watch?v=DQ8HDL-X9rM
The laucher icon does appears in the android simulator but not on physical phones.
what I have tried to do:
clean the build in android studio
reset the icon the way it says in the tutorial
checked the reference in android manifest
checked if the icon was changed in the drawable and mipmap folders
that were the tips that showed up in a stackoverflow topic a couple years back.
I have been working on it for the passed week and I just can't get it to work.
This is my ic_launcher.xml
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="#color/ic_launcher_background"/>
<foreground android:drawable="#mipmap/ic_launcher"/>
</adaptive-icon>
And this is this are the lines in my AndroidManifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
<activity android:name="com.example.fragments.Product">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.MainActivity" />
</activity>
<activity android:name="com.example.MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
Also I checked all the mipmap folders and all my icons are in there with the correct names.
Does anyone know what I can do?
---update june 3---
Now its not even showing up on the emulator anymore...
I have tried and read all the topics online I really hope someone can spot what I do wrong
You can simple way to add icon for app
go to project
app->res->drawable->right click->new->image asset-> source asset
select image path and click to next button
RUN the app
another way

AndroidManifest.xml can not resolve symbol TODO style and drawable

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

Can I set the colour of the Launcher Icon?

I am writing a very simple app as a starter and using a material design icon as the launcher icon. Is there a way I can set the colour of just the launcher icon like I can the size and shape?
Here is my code from AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/gasstation"
android:label="#string/app_name"
android:iconTint="#color/sysGreen"
android:roundIcon="#drawable/gasstation"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The statement android:iconTint seems to be OK in that Android Studio has not flagged it as an error but it has no effect. The launcher icon is still the grey colour of the downloaded image resource.
Is this possible? Any help greatly appreciated.
If you retrieve the icon from a drawable, basically a small image you have in your resources, you cannot change the color.
What you can instead do is to use the tool Image Asset Studio, here is the link
As explained
In the Project window, select the Android view. Right-click the res
folder and select New > Image Asset.
then follow the guide..
Anyway from API version 21, you can tint drawables,
as explained in this post
Well ... I finally did it as follows.
right click on res>new image asset>clip art>pick the icon
you can set the foreground colour manually in the Configure Image Asset screen

Firebase Notification Always shows blank icon

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

Categories

Resources