Skip to content

fix: Don't crash when cropping account avatar or header images#2205

Merged
nikclayton merged 1 commit into
pachli:mainfrom
nikclayton:content-url-cropper
Apr 1, 2026
Merged

fix: Don't crash when cropping account avatar or header images#2205
nikclayton merged 1 commit into
pachli:mainfrom
nikclayton:content-url-cropper

Conversation

@nikclayton

Copy link
Copy Markdown
Contributor

The functions to return the URI for the local file for the avatar and header images weren't going through FileProvider.getUriForFile (e.g., as is done in ComposeActivity) causing a SecurityException on newer Android devices.

java.lang.SecurityException: Only content:// URIs are allowed for security reasons. Received: file://
  at com.canhub.cropper.BitmapUtils.validateOutputUri$cropper_release(BitmapUtils.kt:437)
  at com.canhub.cropper.BitmapUtils.writeBitmapToUri(BitmapUtils.kt:476)
  at com.canhub.cropper.BitmapCroppingWorkerJob$start$1$1.invokeSuspend(BitmapCroppingWorkerJob.kt:96)
  ...

The functions to return the URI for the local file for the avatar and
header images wasn't going through FileProvider.getUriForFile (e.g., as
is done in ComposeActivity) causing a `SecurityException` on newer
Android devices.

```
java.lang.SecurityException: Only content:// URIs are allowed for security reasons. Received: file://
  at com.canhub.cropper.BitmapUtils.validateOutputUri$cropper_release(BitmapUtils.kt:437)
  at com.canhub.cropper.BitmapUtils.writeBitmapToUri(BitmapUtils.kt:476)
  at com.canhub.cropper.BitmapCroppingWorkerJob$start$1$1.invokeSuspend(BitmapCroppingWorkerJob.kt:96)
  ...
```
@nikclayton nikclayton merged commit 258687e into pachli:main Apr 1, 2026
28 checks passed
@nikclayton nikclayton deleted the content-url-cropper branch April 1, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant