"Failed to update Exif data" exception in version 1.5.0

103 views
Skip to first unread message
Assigned to charco...@google.com by tah...@google.com

Tobias Tharaldsen

unread,
Sep 11, 2025, 8:02:29 AMSep 11
to Android CameraX Discussion Group
Hi.
Great work on the new stable version of CameraX with CameraXViewFinder, I'm happy that I now can use the new viewfinder Composable in production code :)


However I'm having a general issue using CameraX with photo capture, it is sometimes giving me this exception:

09-11 10:18:42.241 10798 10798 E CameraDebug: Photo capture failed: Failed to update Exif data

09-11 10:18:42.241 10798 10798 E CameraDebug: androidx.camera.core.ImageCaptureException: Failed to update Exif data

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.FileUtil.updateFileExif(FileUtil.java:119)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.JpegBytes2Disk.apply(JpegBytes2Disk.java:57)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.JpegBytes2Disk.apply(JpegBytes2Disk.java:46)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.ProcessingNode.saveJpegToDisk(ProcessingNode.java:326)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.ProcessingNode.processOnDiskCapture(ProcessingNode.java:286)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.ProcessingNode.processInputPacket(ProcessingNode.java:201)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.ProcessingNode.lambda$transform$0$androidx-camera-core-imagecapture-ProcessingNode(ProcessingNode.java:147)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.ProcessingNode$$ExternalSyntheticLambda7.run(D8$$SyntheticClass:0)

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.lang.Thread.run(Thread.java:1119)

09-11 10:18:42.241 10798 10798 E CameraDebug: Caused by: java.io.IOException: Failed to copy original file to temp file

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.exifinterface.media.ExifInterface.saveAttributes(ExifInterface.java:4921)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.impl.utils.Exif.save(Exif.java:175)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.camera.core.imagecapture.FileUtil.updateFileExif(FileUtil.java:117)

09-11 10:18:42.241 10798 10798 E CameraDebug: ... 10 more

09-11 10:18:42.241 10798 10798 E CameraDebug: Caused by: java.io.IOException: No such file or directory

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.io.UnixFileSystem.createFileExclusively0(Native Method)

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:368)

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.io.File.createTempFile(File.java:2023)

09-11 10:18:42.241 10798 10798 E CameraDebug: at java.io.File.createTempFile(File.java:2069)

09-11 10:18:42.241 10798 10798 E CameraDebug: at androidx.exifinterface.media.ExifInterface.saveAttributes(ExifInterface.java:4908)

09-11 10:18:42.241 10798 10798 E CameraDebug: ... 12 more


I have seen it in version 1.5.0 in:
Samsung Galaxy A52s 5G
Samsung Galaxy S22 5G

I think I was testing on:
Sony Xperia 10 II
when it also happened, but I cleared logcat too quick unfortunately.
This was yesterday using 1.5.0-RC01.

I have a test-user where photo capture always fails, I have not got logs on it yet, but suspects it is the same issue. 
That is on:
Samsung Galaxy Buddy 2
and it is also using the version 1.5.0-RC01

Do you know anything about this issue, and could it be something wrong in my project?

Let me know if you need any more information to help debug.

Some additional info:
  • My app stores photos in app private internal folder (no storage permissions should be required?)
  • I read some place that LocationManager was mentioned related to similar issue, my app uses LocationManager.
  • As mentioned I have a photo issue always happening on Buddy 2, but on A52s and S22 I have only got the issue once so far.
  • The app private folder where photos is stored is created at app launch, so I don't see any possibility that the folder is not existing during photo capture.
  • Video capture works always
  • TargetSdk is 35
  • The different Android versions it has happened on is API 31, 34 and 35.

Tobias Tharaldsen

unread,
Oct 13, 2025, 4:07:44 AMOct 13
to Android CameraX Discussion Group, Tobias Tharaldsen
Hi.
I am still having issues with this in version 1.5.0, it happens sometimes and only for my test-user at the moment (Samsung Galaxy Buddy 2), do you have any suggestions on what to do in order to prevent the exception being thrown, or if it was fixed in 1.5.1?
Could it help to build OutputFileOptions in another way than passing a File in the builder like this? ImageCapture.OutputFileOptions.Builder(imageFile).build() (the path is something like filesDir/myFiles/fileName.jpg)

Charcoal Chen

unread,
Oct 13, 2025, 5:12:20 AMOct 13
to Tobias Tharaldsen, Android CameraX Discussion Group
Hi,

Could you provide some more info for the issue?
1. For the Buddy 2 device, could your test-user update the device to the latest ROM to see whether the issue is fixed by the OEM?
2. Do you specify to set location or some other exif values to the output file?
3. Could you capture the image with OnImageCapturedCallback, save the image buffer data to a file, and then provide it to us for analyzing?

Sometimes, the issue might be caused by the incorrect JPEG byte array data. For example, https://issuetracker.google.com/309005680 is a similar issue.
If possible, we can try to workaround the issue on the CameraX side. This will need your help to provide the problematic JPEG byte array data (#3 above)

Thanks.

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/4b42043a-a7e3-448e-a434-ce18360f1b73n%40android.com.

Tobias Tharaldsen

unread,
Oct 13, 2025, 9:04:57 AMOct 13
to Android CameraX Discussion Group, charco...@google.com, Android CameraX Discussion Group, Tobias Tharaldsen
Thank you for the reply.
Of course, I have to find a good way to implement catching the byte array data first so I don't have the answer for 3. yet, also now after reinstalling the app, the test-user don't get the error at the moment.
1. Test-user is on latest ROM for Europe (where the test-user also is located).
2. I don't specify any manual setting of location metadata or other exif values. I tested with setting location and without, and see that the exif only have location information when I manually add it, so that might mean location is not relevant here.

Charcoal Chen

unread,
Oct 13, 2025, 10:40:51 AMOct 13
to Android CameraX Discussion Group, tobb...@gmail.com, Charcoal Chen, Android CameraX Discussion Group
The issue might only happens under a complex scene. Maybe you can download the "Valid-raya-pinayungan_2022_05_30_09_42_36_1653878556244.jpg" in https://issuetracker.google.com/309005680#comment1. And then, request the test user to take pictures with it to see whether the issue can be reproduced.

If the issue can be reproduced, you can do the following changes in your app to force enable the IncorrectJpegMetadataQuirk (Please be noticed that this is used only for clarifying the issue). And then test again to see whether the issue can be resolved.

Manifest file change:
<service
    android:name="androidx.camera.core.impl.QuirkSettingsLoader$MetadataHolderService"
    android:exported="false"
    android:enabled="false"
    tools:ignore="Instantiatable">
    <meta-data
        android:name="androidx.camera.core.quirks.FORCE_ENABLED"
        android:resource="@array/force_enabled_quirks" />
</service>

Resource file:
<string-array name="force_enabled_quirks">
    <item>androidx.camera.core.internal.compat.quirk.IncorrectJpegMetadataQuirk</item>
</string-array>

Tobias Tharaldsen

unread,
Oct 16, 2025, 6:46:14 AMOct 16
to Android CameraX Discussion Group, charco...@google.com, Tobias Tharaldsen, Android CameraX Discussion Group
Hi.
Thanks for the suggestions, however I think I've found the root cause now which was not a "complex scene" issue.

After debugging with my tester we found out that the issue happened after a sign out of the app, the app code that runs during a sign out clears some data, and it also deleted the app's cache folder(!).
This looks very much to be the issue, it was inconsistent, because the app/OS will automatically recreate the cache folder after a cold start.

I can solve the issue entirely by making adjustment in the app code to only delete cache folder content, and not the folder itself, but could/should CameraX also create the folder if it don't exist? If it can I think it could be a minor improvement to make it even more robust.

Thanks again for the help and suggestions, it helped excluding options and narrowing down where the issue happened :)
Reply all
Reply to author
Forward
0 new messages