Search code examples
androidionic-frameworkionic4capacitor

Ionic app requesting user permission for camera on Android emulator, but not in Ionic DevApp


Problem

I am currently learning Ionic 4 by following this tutorial https://ionicframework.com/docs/angular/your-first-app

However instead of using Cordova like they do in the tutorial I plan on using Capacitor. I followed the Capacitor setup guide and used the camera example given in their official documentation.

I made sure the following permissions are in the AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Then I ran this in my terminal:

ionic capacitor run android --livereload --external

This opens up Android Studio and prepares my project.

Working on Android Emulator

I then press the run selected configuration button which installs the application on my emulator. When I press the camera button I get asked to give the app permission to:

  • Allow app to take pictures and record video?
  • Allow app to access photos, media and files on device

Then it loads up a camera in the emulator like this and I can take a picture as I am supposed to for this tutorial (Embedded image below because it's huge).

Issue with same app using Ionic DevApp

However when I try to use the camera within the Ionic DevApp by manually entering the server URL in capacitor.config.json, I don't get asked for the above permissions. Pressing the exact same button does nothing in the application.

I tried manually giving Ionic DevApp application permission on my physical device but that does not seem to resolve the issue as the button still does nothing.

Emulator

  • Emulator API: 28
  • Emulator Android Target: Android 9.0

Physical device

  • Physical device: Samsung S8+
  • Android version: Android 9.0

Images

Emulator


Solution

  • Ionic devApp is for Cordova only