Help creating app in Google play store - permission to use camera

Hello. I am new here and hope I can get some help.

I am trying to submit my app to the Google Play store manually. When I upload the aab file it tells me I need permission to use the camera.

However, I have the following code in my app.jason file
},
“android”: {
“versionCode”: 1,
“package”: “com.playiit.playiit”,
“permissions”:
},
I have just upgraded eas. This is my current version + eas-cli@0.35.0

Hi @joannecooper

With EAS Build, config plugins for any of your dependencies could add permissions needed by those dependencies. Ideally the config plugin would allow you to specify whether or not you actually want to use the camera (for example) it’s optional. Currently there are some things that should be configurable, but are not yet. e.g. expo-image-picker currently adds Android CAMERA permissions unconditionally.

I think you should probably create an issue on GitHub (if there isn’t one already) with the details from your post here and in addition any dependencies you’re using.

See also @notbrent’s answer about a similar issue here.

If you want to work around this before it’s fixed by the Expo team you should be able to use patch-package to patch the config plugin.

Thank you for your prompt response @wodin Could you please point me in the right direction to learn how to use the patch-package to patch the config plugin?

The instructions are here: patch-package - npm

I’m using yarn, so assuming I was trying to work around this issue in the expo-image-picker package, I would do something like the following:

The dependencies from package.json:

  "dependencies": {
    "expo": "~43.0.2",
    "expo-image-picker": "~11.0.3",
    "expo-status-bar": "~1.1.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-web": "0.17.1"
  },

In node_modules/expo-image-picker there’s a file called app.plugin.js. This is the config plugin’s entry point. You’ll see it only contains the following line:

module.exports = require('./plugin/build/withImagePicker');

So we need to look in node_modules/expo-image-picker/plugin/build/withImagePicker.js. Open that file and remove the lines mentioning android.permission.CAMERA and android.permission.RECORD_AUDIO.

Then run patch-package as follows:

myapp$ npx patch-package expo-image-picker
patch-package 6.4.7
• Creating temporary folder
• Installing expo-image-picker@11.0.3 with yarn
• Diffing your files with clean files
✔ Created file patches/expo-image-picker+11.0.3.patch

💡 expo-image-picker is on GitHub! To draft an issue based on your patch run

    yarn patch-package expo-image-picker --create-issue

Then add the patch to Git:

myapp$ git add patches
myapp$ git commit -m "Don't add CAMERA and RECORD_AUDIO Android permissions"
[master 5f6eff5] Don't add CAMERA and RECORD_AUDIO Android permissions
 1 file changed, 15 insertions(+)
 create mode 100644 patches/expo-image-picker+11.0.3.patch

Then in order for it to work during the build you’ll need to follow the patch-package “Set-up” instructions:

Scripts section from package.json:

  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "postinstall": "patch-package"    
  },

Install patch-package as a dev dependency and commit the changes:

myapp$ yarn add --dev patch-package postinstall-postinstall
[...]
$ patch-package
patch-package 6.4.7
Applying patches...
expo-image-picker@11.0.3 ✔
Done in 4.77s.
myapp$ git commit -am "Install patch-package"
[master a14d8dd] Install patch-package
 2 files changed, 106 insertions(+), 4 deletions(-)

Then try building a package and I think that should solve the problem for now. When the Expo team updates the expo-image-picker package to make the Android permissions configurable, upgrade that package, uninstall patch-package, remove the patches directory and the patch file and remove the post-install script from package.json.

Hi Micheal.
Thank you so much for your detailed response. I really appreciate it. This all sounds a little bit over my head (I am not a developer). I think I am going to go in another direction.

Hi Joanne

It might look complicated, but it’s actually pretty straightforward :slight_smile: (But of course ideally you wouldn’t need to do all of this. It’s just that EAS Build and Config Plugins are all still pretty new, so there are still things that need to be improved.)

Can you confirm that you are in fact using expo-image-picker? If not, then there must be a different dependency adding the CAMERA permission. If you post the dependencies section of your package.json I can check which one is causing this problem.

In addition to my last comment I’ll just say that if you’re using npm to manage your dependencies you will have a package-lock.json file in the root of your project. If you’re using yarn you will have yarn.lock file instead. (You should not have both.)

If you’re using npm then follow my instructions, but instead of running yarn add --dev patch-package postinstall-postinstall you would run npm i patch-package --save-dev.

So, assuming it is expo-image-picker causing the problem, the short version of my last comment would be:

  1. Edit node_modules/expo-image-picker/plugin/build/withImagePicker.js to remove these two lines near the bottom of the file: 'android.permission.CAMERA', and 'android.permission.RECORD_AUDIO',
  2. Run npx patch-package expo-image-picker
  3. Commit the patch to Git
  4. Edit package.json to add a new script: "postinstall": "patch-package". (Just be careful with the commas at the end of the lines. JSON is picky about that. Check my last comment for an example.)
  5. If you’re using npm, run npm i patch-package --save-dev. Otherwise, if you’re using yarn, run yarn add --dev patch-package postinstall-postinstall
  6. Commit the changes to Git
  7. Try building your app again

Good luck.

Hi Micheal
So… maybe if I explain what I am trying to do it may help. I have successfully submitted my app to the ios store and am happy with eas build and eas submit to submit version updates.

Next on my hit list is the Google Play submission process.

  1. I submitted my first build manually to the Google Play store as per the Expo instructions. This build was published to the google play store no problem.
  2. Now I am trying to submit a version update via eas build and eas submit.
  3. I have created the Google Service Account, downloaded the JSON file and saved it into the version’s project directory.
  4. The eas build went without errors
  5. The eas submit now gives me an error “[!] Google Api Error: Invalid request - The caller does not have permission”’

Please see below for the command line. I hope you can help

A Google Service Account JSON key has been found at
  C:\Users\joann\OneDrive\Documents\Draftbit\Playiit13Nov Google\pc-api-5783032609924338076-465-c7dc783aabc6.json
√ Would you like to use this file? ... yes

√ Uploaded Google Service Account Key.
√ Google Service Account Key assigned to com.playiit.playiit for submissions

Project ID:                     296f328a-dc01-48c9-a253-78ceeff9faff
Android package:                com.playiit.playiit
Release track:                  INTERNAL
Changes not sent for a review:  false
Release status:                 COMPLETED
Google Service Account Key:
    Key Source    :  EAS servers
    Account E-mail:  joannecooper@pc-api-9999999999999999999-999.iam.gserviceaccount.com

√ Scheduled Android submission

Submission details: https://expo.dev/accounts/joannecooper/projects/playiit/submissions/2d4a130a-bade-490c-a5be-ce231620fad1

Waiting for submission to complete. You can press Ctrl+C to exit.
× Something went wrong when submitting your app to Google Play Store.

We couldn't figure out what went wrong. Please see logs to learn more.

[logs] Starting uploading Android app
[logs] Downloading archive
[logs] Preparing artifact
[logs] Uploading Android app to Play Store...
[logs] Uploading the app with fastlane
[logs] [!] Google Api Error: Invalid request - The caller does not have permission
[logs] +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
[logs] |                                                                    Summary for supply 2.191.0                                                                     |
[logs] +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
[logs] | aab                             | /tmp/submissions/7f89d291-2778-4bb8-8a42-b987a25a551e/ad7e5fd7_1287_409b_b73d_dc81161e027e_e598ace75588473f9020b48520f27b78.aab |
[logs] | track                           | internal                                                                                                                        |
[logs] | json_key                        | /tmp/submissions/7f89d291-2778-4bb8-8a42-b987a25a551e/service-account.json                                                      |
[logs] | package_name                    | com.playiit.playiit                                                                                                             |
[logs] | changes_not_sent_for_review     | false                                                                                                                           |
[logs] | release_status                  | completed                                                                                                                       |
[logs] | skip_upload_apk                 | false                                                                                                                           |
[logs] | skip_upload_aab                 | false                                                                                                                           |
[logs] | skip_upload_metadata            | false                                                                                                                           |
[logs] | skip_upload_changelogs          | false                                                                                                                           |
[logs] | skip_upload_images              | false                                                                                                                           |
[logs] | skip_upload_screenshots         | false                                                                                                                           |
[logs] | validate_only                   | false                                                                                                                           |
[logs] | check_superseded_tracks         | false                                                                                                                           |
[logs] | timeout                         | 300                                                                                                                             |
[logs] | deactivate_on_promote           | true                                                                                                                            |
[logs] | ack_bundle_installation_warning | false                                                                                                                           |
[logs] +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------+
[logs] fastlane supply failed
[logs] Failed to submit the app

C:\Users\joann\OneDrive\Documents\Draftbit\Playiit13Nov Google>

I have not yet tried out EAS Submit and it’s not clear to me what went when you tried to submit. The error message seems to indicate that the service account doesn’t have the right permissions to be able to submit your app, but I don’t know how to fix it. Sorry.

I hope someone with more experience with using EAS Submit will be able to help with this.

This looks like a separate issue to the initial CAMERA permissions problem, though, so you might want to create a new post for this.

@joannecooper did you ever figure this out? I have the same error. Thank you!