apache / apache/cordova-plugin-file

FileUriExposedException on Android 7+

Open
#270 2 comments 6 reactions 0 assignees View on GitHub
platform: android support
Dominant language
JavaScript
Stars
744
Forks
754
Avg merge
3d 4h
Merged PRs (30d)
1

Description

So we have recently seen that Google will block updates from apps with `targetSdk` < 26. Our apps currently use SDK 23, which works fine. Since then, we were trying to update to Target SDK 26 and comply with Google's definition.

However this plugin does not work with SDK 24+, since it requires you to use `content://` addresses instead of `file:///`. I have tried to find some replacement and updated the plugin to version 6.0.1, but to no avail.

We are also using `@ionic-native/file`, which basically just wraps `cordova-plugin-file` and adds type definitions.

Whenever we try to copy a file to `cordova.file.externalApplicationStorageDirectory` the app crashes, closes, due to a `FileUriExposedException` from `ClipData.Item.getUri()`.

Is there any solution to this?

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash on Android 7+ with targetSdk 26 while copying a file to cordova.file.externalApplicationStorageDirectory, then inspect the plugin's copy operation and its Android URI handling. Done means the same copy completes without FileUriExposedException and remains compatible with the cordova-plugin-file 6.0.1 context.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.