chuanpham / dynamic_icon_flutter

A flutter plugin for IOS app icon changing
MIT License
5 stars 16 forks source link

Changing icon on Android creates a new app #2

Closed sergiyvergun closed 10 months ago

sergiyvergun commented 1 year ago

Every time I'm changing the icon on Android - it creates a new app with selected icon.

image

AndroidManifest.xml:

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

    <uses-feature
            android:name="android.hardware.microphone"
            android:required="false" />
    <uses-feature
            android:name="android.hardware.touchscreen"
            android:required="false" />

    <!-- 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. -->
    <!--        android:requestLegacyExternalStorage="true"-->

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="TextToSpeech.Engine.INTENT_ACTION_TTS_SERVICE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <queries>
        <intent>
            <action android:name="android.intent.action.TTS_SERVICE" />
        </intent>
    </queries>

    <application
            android:icon="@mipmap/ic_launcher"
            android:label="Fleengo"
            tools:targetApi="lollipop"
            tools:ignore="MissingTvBanner">
        <meta-data
                android:name="com.google.firebase.messaging.default_notification_icon"
                android:resource="@drawable/ic_notification" />
        <service
                android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
                tools:ignore="MissingClass" />

        <activity
                android:name=".MainActivity"
                android:exported="true"
                android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
                android:hardwareAccelerated="true"
                android:launchMode="singleTop"
                android:theme="@style/LaunchTheme"
                android:enabled="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). -->
            <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.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                        android:host="fleengo.page.link"
                        android:scheme="https" />
            </intent-filter>

            <meta-data
                    android:name="io.flutter.embedding.android.SplashScreenDrawable"
                    android:resource="@drawable/launch_background" />
            <meta-data
                    android:name="io.flutter.embedding.android.NormalTheme"
                    android:resource="@style/NormalTheme" />
        </activity>

        <activity
                android:name="com.yalantis.ucrop.UCropActivity"
                android:screenOrientation="portrait"
                android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

        <meta-data
                android:name="flutterEmbedding"
                android:value="2" />

        <meta-data
                android:name="com.google.android.gms.ads.APPLICATION_ID"
                android:value="ca-app-pub- ..." />

        <activity-alias
                android:label="Fleengo"
                android:icon="@mipmap/ic_launcher_1"
                android:name=".app_icon_gradient"
                android:enabled="true"
                android:targetActivity=".MainActivity"
                android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity-alias>

        <activity-alias
                android:label="Fleengo"
                android:icon="@mipmap/ic_launcher_2"
                android:name=".app_icon_light"
                android:enabled="false"
                android:targetActivity=".MainActivity"
                android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity-alias>

        <activity-alias
                android:label="Fleengo"
                android:icon="@mipmap/ic_launcher_3"
                android:name=".app_icon_dark"
                android:enabled="false"
                android:targetActivity=".MainActivity"
                android:exported="true">

            <meta-data
                    android:name="io.flutter.embedding.android.NormalTheme"
                    android:resource="@style/NormalTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity-alias>
    </application>

</manifest>

Changing icon in app:

await DynamicIconFlutter.setIcon(
            icon: name,
            listAvailableIcon: [
              'app_icon_gradient',
              'app_icon_light',
              'app_icon_dark'
            ]);

How to fix this?

harshkumarkhatri24 commented 1 year ago

Can you share your project link?

sergiyvergun commented 1 year ago

Can you share your project link?

I can't as it's not open source. I've provided the code here. If you want, we can schedule a call and I'll show you the project.

tientt1304 commented 10 months ago

Can you share your project link?

I can't as it's not open source. I've provided the code here. If you want, we can schedule a call and I'll show you the project.

I am the same. Have you found the solution?

chuanpham commented 10 months ago

Sorry you guys for my late reply, it's been a while since the last time i took a look on this plugin.

Please try to add one more activity-alias like below to check if the problem's gone @tientt1304 @sergiyvergun :

    <activity-alias
     android:label="Your app name"
     android:icon="@mipmap/ic_launcher"
     android:name=".default"
     android:enabled="false"
     android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />       

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity-alias>

And one more thing to check is if do you add the item "MainActivity" to your icon array list like document did mention? const List list = ["icon_1", "icon_2", "icon_n", "default", "MainActivity"]

The latest docs is not on pub.dev right now, please read it here: https://github.com/chuanpham/dynamic_icon_flutter/blob/main/README.md