Comments (18)
OK, I don't know yet how to collect that because as I said, I don't have the errors. Only a couple of users reported this to me and sent me the screenshot. I might try with crashalytics
from gal.
But please, consider adding a
String name = 'image.png'
as aputImageBytes()
paramater.
Please consider submitting an issue that includes reproducible code. Without it, I can do nothing.
from gal.
Hi @alexislg2 π
π©βπ« More detailed debugging information is needed.
Please collect as much of the following data as possible when that error occurs.
GalException.platformException
GalException.stackTrace
image_url
filePath
- Device info with device_info_plus
When the error becomes reproducible, please submit a Bug Report Issue.
Thanksπ
from gal.
I finally managed to get some stacktrace from crashlytics:
- Android 13
- Devie: CPH2247
- image_url = https://media.familinkframe.com/resized/2023/12/15/8ec58fe551764bacb2073979e1ee8558.jpg
- filePath = '${Directory.systemTemp.path}/file.jpg'
Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: [GalException/UNEXPECTED]: An unexpected error has occurred.. Error thrown gal.
at MethodChannelGal._invokeMethod(gal_method_channel.dart:16)
at MethodChannelGal.putImage(gal_method_channel.dart:33)
at SendingCard.build.<fn>(sending_card.dart:120)
from gal.
OK. but there doesn't seem to be any logs that might help identify the cause of the error.
Did you get the GalException.platformException
We need all the values of the PlatformException
. It is very important because that is where the native code errors are stored.
And if you get more than one error,
I would like to know the device and OS trends.
Or is this reproducible?
from gal.
By the way, does the 'sending.image' have the correct url value in it?
from gal.
OK I will release a new version of my app, with more detailed logs in the crashlytics and wait for new logs to come...
This is 100% reproductible. The users who have this error have it 100% of the times, with 100% of the photos they try with.
from gal.
I am trying on Android 13 and cannot reproduce the error.
final path = '${Directory.systemTemp.path}/file.jpg';
await Dio().download(
'https://media.familinkframe.com/resized/2023/12/15/8ec58fe551764bacb2073979e1ee8558.jpg',
path,
);
await Gal.putImage(path, album: 'Familink');
Is the correct image downloaded in filePath
before Gal.putImage
?
from gal.
Solved: the problem was caused by the destination file name: file.jpg
Some rare android devices were not able to overwrite it if a file with a similar name already exists in the album.
new code for downloading:
final uri = Uri.parse(image_url);
final filePath = '${Directory.systemTemp.path}/${uri.pathSegments.last';
await Dio().download(sending.image, filePath);
from gal.
And by the way, with my original code, the file was named file..jpg
instead of file.jpg
because path.extension(uri.path)
is equal to .jpg
, not just jpg
.
from gal.
I'm glad you were able to resolve the issue π @alexislg2
if a file with a similar name already exists in the album.
Is this not album but directory ? This has nothing to do with the gallery, right?
from gal.
Downloading a file to the temporary folder if a file already exists was not the issue. The error was raised when trying to save it to the album (only with some devices again):
[GalException/UNEXPECTED]: An unexpected error has occurred.. Error thrown Failed to save image: java.lang.IllegalStateException: Failed to build unique file: /storage/emulated/0/Pictures/Familink/file..jpg
from gal.
You might consider to update your README. I can make a PR if you like
from gal.
[GalException/UNEXPECTED]: An unexpected error has occurred.. Error thrown Failed to save image: java.lang.IllegalStateException: Failed to build unique file: /storage/emulated/0/Pictures/Familink/file..jpg
Was this caused by a duplicate dot in the extension?
from gal.
I cannot say and I cannot make any test (that would require to push a buggy version of the app in production). According to the error message, I would say it comes from the duplicate
Nevertheless, it's not a good thing to use the same file name as prevent from having multiple photos in the albul
from gal.
The MediaStore API and custom java code should avoid duplicates, so duplicate filenames should not be the cause of the error.
Perhaps the file system did not recognize the file correctly because of the two dots in the file extension.
from gal.
πNote
I now know what the "Failed to build unique file" error message means.
If you try to save a file with a duplicate name, the system avoids this automatically. This is of the form "file(1).jpg". At this time, the system will probably separate the name from the extension by the position of the dot in the extension to generate a unique name. That's why it became such an error when there were two extension dots, as in this case.
from gal.
I have encountered this same error. In my case I use Gal.putImageBytes()
and it saves image as image.png
. Everything was fine, until the image(32).png
, meaning that image(31).png
is created perfectly fine, but next one is not. I've tested it by deleting image(31).png
and it worked fine again, but not after it. I'm testing on POCO F4 with android 13.
I think I'll need to write image to temporary dir with mine own generated name and only then use Gal
. But please, consider adding a String name = 'image.png'
as a putImageBytes()
paramater.
from gal.
Related Issues (20)
- Getting new path of saved image HOT 3
- Is there a way to add an existing file to Gallary? HOT 1
- `album` option is not working on Android API 29
- Consider add some functions to save incoming bytes stream directly to gallery HOT 4
- [iOS] cannot save to target album HOT 11
- Expansion of supported version range of macOS HOT 1
- Unsupported file formats Error for existed files HOT 2
- Add support for Linux desktop platform HOT 13
- Windows platform cannot compile HOT 6
- Open Gallery to album HOT 3
- Allow building macOS apps targeting 10.14 or 10.15 macOS version HOT 3
- Can't compile for windows in lower than C++ 20 HOT 5
- Android: Failed to build unique file HOT 10
- Can "Gal.putImage" return the path of the saved image, instead of void?
- Adding a name parameter in putImageBytes HOT 1
- 2.3.0 not compatible with gal_linux HOT 1
- Next Breaking Change Candidates
- Macos App is crashing when saving image/video from url/asset path HOT 1
- Warning: The plugin gal requires Android SDK version 34. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gal.