Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive icons don't work #31

Closed
mdudek opened this issue Jun 14, 2018 · 18 comments
Closed

Adaptive icons don't work #31

mdudek opened this issue Jun 14, 2018 · 18 comments

Comments

@mdudek
Copy link
Contributor

mdudek commented Jun 14, 2018

When I run flutter pub pub run flutter_launcher_icons:main following exception is thrown:

FileSystemException: Cannot copy file to 'android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml', path = '../assets/ic_launcher.xml' (OS Error: The system cannot find the file specified.

It seems that there is some problem with relative path '../assets/ic_launcher.xml' used in android.dart file.

@MarkOSullivan94
Copy link
Collaborator

MarkOSullivan94 commented Jun 14, 2018

@mdudek thanks for reporting this!

Will try and do some investigation. Curious if this is just an issue with windows or if it affects all platforms. I'm using Linux.

@markmooibroek pinging you in case you get a chance to check it out before I do.

@markmooibroek
Copy link
Contributor

Ill have a look, i used the dart ../bin/main.dart command from the example folder so never got to experience this error. Will try to see if i can reproduce it

@markmooibroek
Copy link
Contributor

Hmm seems to be working perfectly on MacOS then doing the flutter pub pub run flutter_launcher_icons:main command from the example. Don't have a Windows PC at hand to test upon :-(

@MarkOSullivan94
Copy link
Collaborator

@mdudek are you getting this issue in the example project or when you actually run the plugin on a real project?

@mdudek
Copy link
Contributor Author

mdudek commented Jun 14, 2018

I'm using plugin on my flutter project.

@lukaspili
Copy link

Same issue on MacOS, on new project.

Pubspec:

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_launcher_icons: "^0.5.0"
  
flutter_icons:
  android: true 
  ios: true
  image_path: "assets/icon/icon.png"
  adaptive_icon_background: "#FDF9F5"
  adaptive_icon_foreground: "assets/icon/icon-android-foreground.png"

Running command from the root folder of the project: flutter pub pub run flutter_launcher_icons:main results in the error stated above.

Complete stack trace:

FileSystemException: Cannot copy file to 'android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml', path = '../assets/ic_launcher.xml' (OS Error: No such file or directory, errno = 2)
#0      _File.throwIfError (dart:io/file_impl.dart:647)
#1      _File.copySync (dart:io/file_impl.dart:352)
#2      createAdaptiveIcons (package:flutter_launcher_icons/android.dart:75:12)
#3      createIcons.<anonymous closure> (package:flutter_launcher_icons/main.dart:28:7)
#4      _RootZone.runUnary (dart:async/zone.dart:1381)
#5      _FutureListener.handleValue (dart:async/future_impl.dart:129)
#6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638)
#7      Future._propagateToListeners (dart:async/future_impl.dart:667)
#8      Future._complete (dart:async/future_impl.dart:472)
#9      _SyncCompleter.complete (dart:async/future_impl.dart:51)
#10     _completeOnAsyncReturn (dart:async-patch/dart:async/async_patch.dart:292)
#11     loadConfigFile (package:flutter_launcher_icons/main.dart:38:3)
#12     _RootZone.runUnary (dart:async/zone.dart:1381)
#13     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#14     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:638)
#15     Future._propagateToListeners (dart:async/future_impl.dart:667)
#16     Future._completeWithValue (dart:async/future_impl.dart:482)
#17     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:512)
#18     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#19     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#20     _runPendingImmediateCallback (dart:isolate-patch/dart:isolate/isolate_patch.dart:113)
#21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:166)

This could probably be fixed and be made more robust by using https://pub.dartlang.org/packages/path, although I didn't try myself if it fixes the issue.

@sam0610
Copy link

sam0610 commented Jun 15, 2018

same problem here

@MarkOSullivan94
Copy link
Collaborator

MarkOSullivan94 commented Jun 15, 2018

@lukaspili I think I've seen a similar error before. I'll try and get a fix out tonight.

Thanks for posting the stack trace!

@MarkOSullivan94
Copy link
Collaborator

Working on a fix for this. There's a XML package which looks like it will allow me to use a string to generate an XML file and so means we can get rid of the assets folder with the ic_launcher.xml and colors.xml files and just create a new dart file to act as a template having a string for each file.

@MarkOSullivan94 MarkOSullivan94 changed the title Adaptive icons don't work (windows platform) Adaptive icons don't work Jun 16, 2018
@MarkOSullivan94
Copy link
Collaborator

Seems to be working again in the example having replaced relative paths with string alternatives based in a template dart file: #32

@MarkOSullivan94
Copy link
Collaborator

MarkOSullivan94 commented Jun 18, 2018

@mdudek @lukaspili @sam0610 let me know if 0.5.1 fixes this, just published it.

@mdudek
Copy link
Contributor Author

mdudek commented Jun 19, 2018

Just tried v0.5.1 and it runs without error. But it seems that app icon is not 'adaptive', there is still used classic 'non-adaptive' version of icon in launcher after apk installation.

@MarkOSullivan94
Copy link
Collaborator

I'm glad there's no error appearing now.

I'm wondering if the adaptive icon isn't working because I changed the directory from mipmap-anydpi-v26 to mipmap-v26, thought it should have worked.

Are you running the example project or your own?

@markmooibroek
Copy link
Contributor

According to the android docs it needs to be in the mipmap-anydpi (or mipmap-anydpi-v26 to work in combination with lower API levels). I think this is because its an xml file rather than a png.

https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive

Next you must create alternative drawable resources in your app for use with Android 8.0 (API level 26) in res/mipmap-anydpi/ic_launcher.xml

@MarkOSullivan94
Copy link
Collaborator

That must be it! I'll change that tonight and do another quick test before releasing it.

My mistake changing it, thought it should have still worked as long as v26 was in it. Apologies for changing that @markmooibroek. I'm going to put that quote in as a comment in the code to make sure I never forget about it.

Might be good to add a unit test to make sure that the directory will always be mipmap-anydpi-v26.

@MarkOSullivan94
Copy link
Collaborator

Heads up everyone v0.5.2 available now. Did a local test before publishing and it's working again for me! Hope it works for everyone else.

@hyperobject
Copy link

Adaptive icons are working for me with v0.5.2! 😃

@mdudek
Copy link
Contributor Author

mdudek commented Jun 20, 2018

Confirmed ;-)

@mdudek mdudek closed this as completed Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants