32

I want to change my app icon in flutter using flutter_launcher_icons: ^0.9.2
It shows me errors while I'm running Command flutter pub run flutter_launcher_icons:main
Image of the error


I tried many times but no new results

Yassin Elshaiatany
  • 323
  • 1
  • 3
  • 7

6 Answers6

89

I just had the same problem and solved doing this in android/app/build.gradle.

Changed:

minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion

To:

minSdkVersion 26
targetSdkVersion 30

Source

[Edit] After that, I could not run on emulator, so I changed back the gradle file (without running flutter_launcher_icon again). Now I have the app running and the icons are right.

Iagows
  • 1,049
  • 9
  • 8
3

Thanks to this answer, I was able to fix the issue!

Oli
  • 369
  • 4
  • 8
1

If the solution proposed by @Iagows doesn't work for you, have a look at this: flutter_launcher_icons-issues

Deffo
  • 191
  • 1
  • 8
  • 21
1

Inside file: ~/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_launcher_icons-0.9.2/lib/android.dart

Replace Line:

 final String minSdk = line.replaceAll(RegExp(r'[^\d]'), '');
 To this:
 final String minSdk = "21"; // line.replaceAll(RegExp(r'[^\d]'), '');

Save the file and then run:

    flutter pub get
    flutter pub run flutter_launcher_icons:main

Source : https://github.com/fluttercommunity/flutter_launcher_icons/issues/324

  • this should be the answer, it goes directly to source of the problem and fix it without interfering with our build gradle – Raiden Core Jun 01 '22 at 18:39
1

I just changed the package version in pubspec.yaml and that solved the problem for me.

dependencies:
  flutter_launcher_icons: ^0.10.0
Gedeon Mutshipayi
  • 2,871
  • 3
  • 21
  • 42
-1

The issue is explained in the readme of the plugin, section "Dependency incompatible". It says

Because flutter_launcher_icons >=0.9.0 depends on args 2.0.0 and flutter_native_splash 1.2.0 depends on args ^2.1.1, flutter_launcher_icons >=0.9.0 is incompatible with flutter_native_splash 1.2.0.
And because no versions of flutter_native_splash match >1.2.0 <2.0.0, flutter_launcher_icons >=0.9.0 is incompatible with flutter_native_splash ^1.2.0.
So, because enstack depends on both flutter_native_splash ^1.2.0 and flutter_launcher_icons ^0.9.0, version solving failed.
pub get failed

The solution is given in as cryptic a manner as the description above, but the simple hack given by @deffo worked for me. https://github.com/fluttercommunity/flutter_launcher_icons/issues/324#issuecomment-1013611137

What you do is that you skip the version solving done when the plugin reads build.gradle and you force minSdkVersion to be whatever version you prefer.

It's a hack but since you generate automatically the app icons only once and for all, who cares? :-)

BTW, the following solution seems cleaner but I didn't test it: https://github.com/fluttercommunity/flutter_launcher_icons/issues/262#issuecomment-877653847