Coder Social home page Coder Social logo

Comments (18)

alexislg2 avatar alexislg2 commented on May 12, 2024 1

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024 1

But please, consider adding a String name = 'image.png' as a putImageBytes() paramater.

Please consider submitting an issue that includes reproducible code. Without it, I can do nothing.

from gal.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

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.

alexislg2 avatar alexislg2 commented on May 12, 2024

I finally managed to get some stacktrace from crashlytics:

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

By the way, does the 'sending.image' have the correct url value in it?

from gal.

alexislg2 avatar alexislg2 commented on May 12, 2024

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

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.

alexislg2 avatar alexislg2 commented on May 12, 2024

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.

alexislg2 avatar alexislg2 commented on May 12, 2024

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

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.

alexislg2 avatar alexislg2 commented on May 12, 2024

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.

alexislg2 avatar alexislg2 commented on May 12, 2024

You might consider to update your README. I can make a PR if you like

from gal.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

[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.

alexislg2 avatar alexislg2 commented on May 12, 2024

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

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.

natsuk4ze avatar natsuk4ze commented on May 12, 2024

πŸ“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.

Lo4D avatar Lo4D commented on May 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.