codebird / flutter_app_icons

MIT License
2 stars 5 forks source link

Facing an issue while integrating for android #2

Open Joel134 opened 1 year ago

Joel134 commented 1 year ago

Hi @codebird , I wanted to have dynamic change of app icon in my App, So i used your package "flutter_app_icons" for doing so. But on testing i am facing an issue which says:

D/Flutter App Icons( 3233): You need to update AndroidManifest.xml, please refer to README. Component class com.example.myApp. does not exist in com.example.myApp

I also tried running the example app which works well though. So i assume i am making some mistake. I had followed exactly the same steps which you have mentioned in readme. Can you help with what did i missed out.

codebird commented 1 year ago

Hello Joel,

Thanks for reaching out, and I hope I can help.

Can you show me the content of the file:

android/app/src/main/AndroidManifest.xml

Joel134 commented 1 year ago

Thanks for looking into this. Yeah sure I can share

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

<queries>
 <intent>
      <action android:name="android.intent.action.SEND" />
      <data android:mimeType="*/*" />
 </intent>

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

<application android:label="@string/app_name" android:usesCleartextTraffic="true" tools:replace="android:usesCleartextTraffic" android:icon="@mipmap/ic_launcher" android:theme="@style/YourLightTheme1" android:allowBackup="false"> <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" 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"/>
             <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
        </intent-filter>

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

  <activity-alias
  android:name=".image1.png"
  android:roundIcon="@mipmap/ic_launcher"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:enabled="true"
  android:exported="true"
  android:targetActivity=".MainActivity">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
  </activity-alias>

  <activity-alias
  android:name=".image2.png"
  android:roundIcon="@mipmap/image2"
  android:label="@string/app_name"
  android:icon="@mipmap/image2"
  android:enabled="false"
  android:exported="true"
  android:targetActivity=".MainActivity">
  <intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
  </activity-alias>

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

</application>

` and this is how i set the app icon in my UI Code

onPressed: () { _flutterAppIconsPlugin.setIcon(icon: 'image2.png'); }

I get the above error when i tap on the button to switch the icon

codebird commented 1 year ago

Joel, I see 2 issues:

1- is android:label correct in the manifest? 2- as it is said in the readme.md, you for android to work, you need to call the function with 2 parmaters, icon and oldIcon

_flutterAppIconsPlugin.setIcon(icon: 'image2.png', oldIcon: 'image1.png');
Joel134 commented 1 year ago

@codebird, I checked the android:label which is right one. I missed to add old icon before i tried but still didn't help, i got an error which says

D/Flutter App Icons(21528): You need to update AndroidManifest.xml, please refer to README. Component class com.example.myApp.image1.png does not exist in com.example.myApp

I did this: _flutterAppIconsPlugin.setIcon(icon: 'image2.png', oldIcon: 'image1.png');

codebird commented 1 year ago

@Joel134 1 last thing, please past the whole manifest file, as it is missing some pieces up there. The last code you pasted the correct way of doing it, as the plugin disables an activity alias, and activates the other. I think there should be some simple typo in your manifest file. The one you pasted up there isn't complete

Joel134 commented 1 year ago

Sure @codebird, I am attaching one screen shot

image
Joel134 commented 1 year ago

Hi, any update on this issue?

On Wed, May 31, 2023 at 7:16 PM Hicham Mallah @.***> wrote:

@Joel134 https://github.com/Joel134 1 last thing, please past the whole manifest file, as it is missing some pieces up there. The last code you pasted the correct way of doing it, as the plugin disables an activity alias, and activates the other. I think there should be some simple typo in your manifest file. The one you pasted up there isn't complete

— Reply to this email directly, view it on GitHub https://github.com/codebird/flutter_app_icons/issues/2#issuecomment-1570269402, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQGENEFBCS6KCRNWMW6PNXTXI5DSDANCNFSM6AAAAAAYVA2VBY . You are receiving this because you were mentioned.Message ID: @.***>

codebird commented 1 year ago

Hello

Sorry was busy, I just took a fast look, and I see that the manifest a bit weird the package is com.example.myApp, while all the rest you're using app_name

Check the manifest with the example app, in this repo, see the differences.