cordova-plugin-camera
cordova-plugin-camera copied to clipboard
Cannot open camera only on Google Pixel 3
Bug Report
Problem
Cannot use camera app after migration on cordova-android@latest and cordova-plugin-camera@latest versions on GP-3.
Tested on
- huawei p20 pro - android 10 / IMUI 10
- huawei p30 - android 10 / IMUI 11
- Google Pixel 4 - android 11
- Google Pixel 3 emulator
All this devices can open camera app without problem.
target SDK 30
Related to #734, #673
I don't have any access to the client logs to see what was happens. Any idea?
Do we need to add this permission? https://developer.android.com/reference/android/Manifest.permission#CAMERA
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Cannot really speak on the root issue but
Do we need to add this permission? https://developer.android.com/reference/android/Manifest.permission#CAMERA
This permission is only used for apps that uses the Camera APIs directly. This plugin does not use the Camera APIs. Instead it uses what Android calls Intents, which is to delegate the responsibility of taking an image using the camera by launching another app which does have the Camera
permissions already to handle the camera operations. This is the recommended approach to use by Google and covers the needs of most apps.
There is one caveat however, if the application declares that the app uses the Camera
permission, then you must have the Camera permission to use Intents. This is a case already handled via:
https://github.com/apache/cordova-plugin-camera/blob/0fba37cac3d2053d4c5f8acbb2cf0c5dbd0903be/src/android/CameraLauncher.java#L125
and
https://github.com/apache/cordova-plugin-camera/blob/0fba37cac3d2053d4c5f8acbb2cf0c5dbd0903be/src/android/CameraLauncher.java#L252-L284
@breautek manual adding permission.CAMERA
fix the problem on GP3!
@WuglyakBolgoink How/where are you adding that? My AndroidManifest.xml already includes <uses-permission android:name="android.permission.CAMERA" />
, but I've still got this issue on my GP3.
Hallo @beard7
@WuglyakBolgoink How/where are you adding that? My AndroidManifest.xml already includes
<uses-permission android:name="android.permission.CAMERA" />
, but I've still got this issue on my GP3.
- install
"cordova-custom-config": "5.1.0"
- check your config
- add custom config for CAMERA permission, because original cordova "edit-config" remove the first permission from manifest file!!!
- remove your platform folder
- generate platform folder again
<widget ...>
...
<preference name="cordova-custom-config-autorestore" value="false" />
<preference name="cordova-custom-config-stoponerror" value="true" />
...
<platform name="android">
<preference name="AndroidLaunchMode" value="singleTask" />
<preference name="android-minSdkVersion" value="22" />
<preference name="android-maxSdkVersion" value="31" />
<preference name="android-targetSdkVersion" value="30" />
<preference name="AndroidXEnabled" value="true" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']">
<activity xmlns:tools="http://schemas.android.com/tools" />
</edit-config>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:name='MainActivity']">
<activity android:requestLegacyExternalStorage="true" />
</edit-config>
<custom-config-file parent="./" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.CAMERA" />
</custom-config-file>
</platform>
...
</widget>
After that we can use camera on GP3 again...