Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Opening camera/gallery does not work on Android 11 #2531

Closed
1 of 5 tasks
kidroca opened this issue Apr 22, 2021 · 19 comments · Fixed by #3420
Closed
1 of 5 tasks

[Android] Opening camera/gallery does not work on Android 11 #2531

kidroca opened this issue Apr 22, 2021 · 19 comments · Fixed by #3420
Assignees
Labels
Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Weekly KSv2

Comments

@kidroca
Copy link
Contributor

kidroca commented Apr 22, 2021

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Expected Result:

Image picking should work on any native platform

Actual Result:

Launching the camera or opening the gallery does not work on Android 11 devices

Action Performed:

  1. Have an Android SDK Level 30 device (Android 11)
  2. Open a chat
  3. Press the plus button (+)
  4. Tap on "Add Attachment"
  5. Select "Take Photo" or "Choose from Gallery"
  6. Observe error message "An error occurred while selecting an attachment..."

Workaround:

Add the attachment through "Choose Document" or add it from web or mWeb

Platform:

Where is this issue occurring?

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: 1.0.28-0
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

Android.Emulator.-.Samsung_Galaxy_S10_API_30_5554.2021-04-22.10-43-32.mp4

Expensify/Expensify Issue URL:

view job on upwork here

View all open jobs on Upwork

@kidroca kidroca changed the title Update image picker from v2 (legacy) to v3 [Android] Opening camera/gallery does not work on Android 11 Apr 22, 2021
@kidroca
Copy link
Contributor Author

kidroca commented Apr 22, 2021

I've confirmed the issue only happens on devices running Android 11. Installing the app on a device running Android 10 has no issues

Why this particular issue happens is described in the details section

Proposal

The imager picker library version 2 used is no longer maintained. The author suggestion for any issues occurring on v2 is to migrate to v3

Since we've already make the shift to present our own attachment options, we can easily migrate to v3

Along the way the suggestion on error handling using codes can be applied as well: https://github.com/Expensify/Expensify.cash/pull/1036/files#r550156553


Details

This particular issue is related to moving to Android SDK 30 1bcf23b

https://developer.android.com/training/data-storage/use-cases#opt-out-in-production-app

Caution: After you update your app to target Android 11 (API level 30), the system ignores the requestLegacyExternalStorage attribute when your app is running on Android 11 devices, so your app must be ready to support scoped storage and to migrate app data for users on those devices.

This was initially configured when the attachment picker was included to the app:
https://github.com/Expensify/Expensify.cash/blob/1bcf23b73a12d34c2cc1b09035105ee50fcabc5f/android/app/src/main/AndroidManifest.xml#L16

Here: https://github.com/Expensify/Expensify.cash/pull/463/files#diff-63272c98a6330850888e633b43ba4c9decee6431a115e0d2731564838eaa1d1dR15

As noted this is not a permanent solution: react-native-image-picker/react-native-image-picker#1447 (comment)

API 30 probably introduces updates that aren't handled in v2 of the library particularly this

your app must be ready to support scoped storage

react-native-image-picker/react-native-image-picker#1492 (comment)

3.x.x is compatible with scoped storage


Alternative

Install another image picker library like: expo's Image Picker https://docs.expo.io/versions/latest/sdk/imagepicker/

The plus side for this one is that it supports web as well. This means it will be possible to remove the custom web specific attachment picker that we use

The negative is installing this library would drag with it self the uni-modules - additional stuff we might never use.
Also there would be a lot more changes involved

Support for web might be included in react-native-image-picker at some point react-native-image-picker/react-native-image-picker#1430 (comment)

@arielgreen arielgreen added the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Apr 28, 2021
@MelvinBot
Copy link

Triggered auto assignment to @sonialiap (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

@MelvinBot MelvinBot removed the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Apr 28, 2021
@arielgreen arielgreen added the Daily KSv2 label Apr 28, 2021
@kidroca
Copy link
Contributor Author

kidroca commented May 6, 2021

The document picker library used in the AttachmentPicker is also one version below the latest major version

https://github.com/Expensify/Expensify.cash/blob/718cd65bc13d8b225c550af19280c23809b4f558/package.json#L74

It can be updated as well, but the minimum supported Android API Level should also be updated to 21 (Android 5.0 December 2014) as it's a requirement for v5
https://github.com/rnmods/react-native-document-picker/releases/tag/v5.0.0

breaking: support only android >=5 (API 21)

Current minimum API level is 16 (Android 4.1 October 2012)

https://github.com/Expensify/Expensify.cash/blob/718cd65bc13d8b225c550af19280c23809b4f558/android/build.gradle#L6

My suggestion is to migrate both attachment related libraries to their latest versions in this ticket.

@sonialiap sonialiap removed their assignment May 21, 2021
@sonialiap sonialiap added Engineering Improvement Item broken or needs improvement. Weekly KSv2 and removed Daily KSv2 labels May 21, 2021
@MelvinBot
Copy link

Triggered auto assignment to @madmax330 (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@madmax330 madmax330 added the External Added to denote the issue can be worked on by a contributor label May 26, 2021
@MelvinBot
Copy link

Triggered auto assignment to @jboniface (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@jboniface
Copy link

job posted cc @kidroca

@jboniface jboniface removed the Daily KSv2 label May 26, 2021
@FaisalAshraf44
Copy link

FaisalAshraf44 commented May 26, 2021

it should work by adding this line
android:requestLegacyExternalStorage="true"
to <application ... > tag in AndroidManifest.xml

@mallenexpensify mallenexpensify self-assigned this May 27, 2021
@kidroca
Copy link
Contributor Author

kidroca commented Jun 2, 2021

@mallenexpensify
I was invited to submit a proposal in Upwork and I did: https://www.upwork.com/ab/proposals/1397658468846395392
But @jboniface told me that someone else will look at it as he's ooo, though no one else have responded since

@jboniface
Copy link

jboniface commented Jun 2, 2021

@kidroca yeah it looks like there was a little miscom here, matt was going to flag this for engineering while I was out but it must have slipped through the cracks (I'm back now though and will reach out)

@MelvinBot
Copy link

Triggered auto assignment to @timszot (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@jboniface jboniface assigned timszot and unassigned timszot and madmax330 Jun 2, 2021
@timszot
Copy link
Contributor

timszot commented Jun 2, 2021

@kidroca That proposed solution looks good to me. Let's go with that over the alternative library you mention. One note, I see that our minSdkVersion is already set to 21 since this was posted, so we should be good there.

@mallenexpensify
Copy link
Contributor

Sorry @kidroca and @jboniface , I wasn't paying close-enough attention to know I was supposed to check Upwork to hire @kidroca . :|

@jboniface
Copy link

no worries, I should have applied the exported label instead of pinging you but I keep forgetting that step 😅 ; @kidroca I've hired you in UW for this

@kidroca
Copy link
Contributor Author

kidroca commented Jun 4, 2021

I've got the job on Upwork

@kidroca
Copy link
Contributor Author

kidroca commented Jun 7, 2021

Shouldn't I also be assigned to the ticket here on github?

@jboniface jboniface assigned kidroca and unassigned mallenexpensify Jun 7, 2021
@jboniface
Copy link

@kidroca yep, good point

@kidroca
Copy link
Contributor Author

kidroca commented Jun 11, 2021

The PR for this issue is ready for review

@kidroca
Copy link
Contributor Author

kidroca commented Jun 28, 2021

@jboniface
I've receive payment for this task, but never received a 150$ bonus for discovering and creating the issue

@jboniface
Copy link

@kidroca ah, sorry, I was batching these the other day and missed that you filed it. i'll add the 150 to the other issue we owe you for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering External Added to denote the issue can be worked on by a contributor Improvement Item broken or needs improvement. Weekly KSv2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants