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

Error when building Android release with flutter_vector_graphics_compiler on Windows #2180

Closed
GiampaoloGabba opened this issue May 31, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@GiampaoloGabba
Copy link

Description

When attempting to build an Android release on Windows with the flutter_vector_graphics_compiler package in my app,i get an Access Denied error during the SVG compilation process. Sometimes the error is slightly different, indicating File not found

I already checked files and folder permissions. I even modified the standard temp folder, assigned full controll for everyone and tried to run shorebird as administrator.

Error details

Target aot_android_asset_bundle failed: Error: User-defined transformation of asset "D:\xxxxxx\assets\icons\svg\apple_icon.svg" failed.
Transformer process terminated with non-zero exit code: 255
Transformer package: vector_graphics_compiler
Full command: C:\Users\xxxxxx\.shorebird\bin\cache\flutter\985ec84cb99d3c60341e2c78be9826e0a88cc697\bin\cache\dart-sdk\bin\dart.exe run vector_graphics_compiler --input=C:\Temp\flutter_tools.9ee00a10\apple_icon.svg-transformOutput0.svg --output=C:\Temp\flutter_tools.9ee00a10\apple_icon.svg-transformOutput1.svg
stdout:

stderr:
Cannot rename file to 'D:\xxxxxx\.dart_tool/pub\bin\vector_graphics_compiler\vector_graphics_compiler.dart-3.4.1.snapshot', path = 'D:\xxxxxx\.dart_tool/pub\bin\vector_graphics_compiler\tmp21148a30\vector_graphics_compiler.dart-3.4.1.snapshot.incremental.temp' (OS Error: Access Denied.
, errno = 5)
PathAccessException: Cannot rename file to 'D:\xxxxxx\.dart_tool/pub\bin\vector_graphics_compiler\vector_graphics_compiler.dart-3.4.1.snapshot', path = 'D:\xxxxxx\.dart_tool/pub\bin\vector_graphics_compiler\tmp21148a30\vector_graphics_compiler.dart-3.4.1.snapshot.incremental.temp' (OS Error: Access Denied.
, errno = 5)

Observations

During the build process, a temporary directory (e.g., flutter_tools.c65cea74) is created in the Temp folder where the SVG files are stored for compilation. However, it seems to me that this directory is deleted before the SVG compiler starts, crashing everything. Maybe it's not true i don't have a precise test, just my observation.

Steps to Reproduce

  1. Set up a Flutter project on Windows.
  2. Add the flutter_vector_graphics_compiler package to the project.
  3. Attempt to create an Android release using Shorebird.
  4. Observe the error during the build process.

Environment

  • Operating System: Windows
  • Shorebird Version: 1.1.8
  • Flutter Version: 3.22.1
  • flutter_vector_graphics_compiler Version: 1.1.11+1
@GiampaoloGabba GiampaoloGabba added the bug Something isn't working label May 31, 2024
@eseidel
Copy link
Contributor

eseidel commented May 31, 2024

This seems like a windows error. Probably caused by one of two things:

  1. The paths in question are in use by another process (windows doesn't let you delete files or directories which are in use by another process)
    or
  2. Some thing in that directory (.dart_tool, which is dart's cache directory) was created by another user (e.g. an admin) possibly by running from within a powershell admin process or similar, and now can't be changed by this non-admin user.

That said, I could be completely wrong. I have not yet tried your repro steps but am happy to.

I'd probably start by trying to remove the .dart_tool directory and rebuild and see if it fixes it.

@eseidel eseidel added this to 1.1 May 31, 2024
@eseidel eseidel moved this to Customers in 1.1 May 31, 2024
@GiampaoloGabba
Copy link
Author

I dont know. i tried to remove everything. i also reinstalled dart, flutter & shorebird, disabled windows defender, rebooted, nothing changed.
There was a similar issue #840 that is closed, but i dont think the problem is some windows process locking the folder.

I also have the shorebird clean problem. I checked everything with tool like powertoys locksmith or LockHunter, and these folder are not locked.
Just to be sure i create a small .net core console application that just delete the contents in in the shorebird folder, and it works without problems (i run it with the same privileges as the shorebird cli).

I'm afraid that there is something in the shorebird cli that does not handle correctly files and folder in windows under some circustances.
Files are not locked, permissions well.. i removed all permission, everyone can do anything with those folders, also other console applications can delete the same files that shorebird cli cant, but i really dont know how to help here :(
if you need more information about my system, more logs info ecc... just ask, happy to help where i can !

@GiampaoloGabba
Copy link
Author

maybe there is something between shorebird cli and dart.exe that are locking out each other?

@eseidel
Copy link
Contributor

eseidel commented Jun 4, 2024

I suspect next steps here would be for one of us to try adding shorebird to https://github.com/dnfield/vector_graphics/tree/main/packages/vector_graphics/example and see if there is any failure? My guess is that there isn't anything shorebird-specific going on here, just a windows permissions issues caused by having run a command with administrator and that command having left around some cache files created by an administrator which then cannot be deleted/modified by a non-administrator account.

@GiampaoloGabba
Copy link
Author

ok, i made some other tests. it is definitely something with vector_graphics, not shorebird.
I recently bought a new mac and started developing with it and encountered the same problem...

The solution is... just retry until it works :)

  1. Usually i run the command (first i close intellij, just to be sure)
  2. it fails, so i delete .dart_tools inside the project
  3. Rerun, sometimes it works (50/50)
  4. Retry until it works (usually on 3rd or 4th try).

i just need to be resilient and retry until it works. All of this happens only when compiling for Android, when creating an ipa for IOS i have never encountered this problem.

So, in the end is clear that this is not a shorebird problem. it happens mostly when using the shorebird cli though, i dont know why. Compiling with just flutter also sometime fails but tipycally i need just to remove .dart_tools and retry just 1 time.

but i suppose we can close this here, it does not belong to shorebird, sorry!

@eseidel
Copy link
Contributor

eseidel commented Jun 4, 2024

Thanks. I'm going to leave this open for now.

Unfortunately the maintainer for vector_graphics is no longer around (I don't know what, if any, plans there are for maintenance going forward). shorebird does mostly just call flutter build ipa under the covers. You can see all the commands we run with shorebird release ios -v.

@eseidel eseidel closed this as completed Jun 12, 2024
@github-project-automation github-project-automation bot moved this from Customers to Done in 1.1 Jun 12, 2024
@corepuncher
Copy link

corepuncher commented Aug 29, 2024

I had the same issue (windows environment, building Android), and this worked for me:

icacls "C:\Users\me\projectDir" /reset /t /c /l

EDIT: I was only able to build it one time. Ugh.

@corepuncher
Copy link

Thanks. I'm going to leave this open for now.

Unfortunately the maintainer for vector_graphics is no longer around (I don't know what, if any, plans there are for maintenance going forward). shorebird does mostly just call flutter build ipa under the covers. You can see all the commands we run with shorebird release ios -v.

FYI, I started a new issue here:

flutter/flutter#159058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants