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

No Image Data on Android 12 #900

Open
s5nicolay-dev opened this issue Oct 22, 2024 · 7 comments
Open

No Image Data on Android 12 #900

s5nicolay-dev opened this issue Oct 22, 2024 · 7 comments

Comments

@s5nicolay-dev
Copy link

Running fine on Android 10 (API level 29) with cordova Android 13.0.0 on Bluebird EF550.

Fails on Android 12 (API level 32) with cordova Android 13.0.0 on Bluebird EF551 with error message "No Image Data".

The project is a clean cordova HelloWorld project.
cordova create test
cordova platform add android
cordova plugin add cordova-plugin-camera
cordova build android

In console:
var srcType = Camera.PictureSourceType.CAMERA;
var options = setOptions(srcType);

function setOptions(srcType) {
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: srcType,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
allowEdit: false,
correctOrientation: true
}
return options;
}

navigator.camera.getPicture(function cameraSuccess(imageUri) {
console.log("haha yes");
}, function cameraError(error) {
console.debug(error);
}, options);

Any suggestions?

@breautek
Copy link
Contributor

"No Image Data"

this usually indicates that the intent was cancelled and the user didn't select any image or didn't capture any image.

However on factory fresh devices when the user opens up the camera on the very first time I noticed that the camera app responds this way when it requests permission to use geolocation. Perhaps this is also what you're experiencing?

@s5nicolay-dev
Copy link
Author

Thank you for the suggestion. It sounds plausible that there is no image captured.

For the record it works to select PHOTOLIBRARY source and upload an image, however not capture.

We have tried factory reset on the device without luck. The app requests permission and launches the camera, however no data returns and the error function is called. I have tried to enable and disable the Geolocation for the camera app.

@breautek
Copy link
Contributor

Can you try testing the dev build?

cordova plugin remove cordova-plugin-camera
cordova plugin add https://github.com/apache/cordova-plugin-camera.git

It is a new major so it includes several breaking changes which is currently noted in the docs PR that will be used for the announcement when it's formally released: apache/cordova-docs#1374

But it contains significant improvements for Android kinda across the board.

Otherwise I'd suggest opening the project in Android Studio or use logcat to get the native logs to see if there is anything there that indicates why it's returning "No Image"

@s5nicolay-dev
Copy link
Author

s5nicolay-dev commented Oct 30, 2024

Thanks for the advice!

I have just tested and still have the same issue. I will try to see if I can find anything in logcat, but not quite sure what to look for.

What I am trying is a clean HelloWorld cordova app (cordova create test) with cordova-plugin-camera 8.0.1-dev and Android 13 platform. The device is a Bluebird EF551R that is factory reset. The capture still calls error function with the error message "No Image Selected".

@s5nicolay-dev
Copy link
Author

I have noticed that the app has not requested access to (listed with access to) Camera in the device settings.

@breautek
Copy link
Contributor

I have just tested and still have the same issue. I will try to see if I can find anything in logcat, but not quite sure what to look for.

I'd suggest filtering logcat by your application id. Android Studio will do this by default if you run the project via Android Studio. (Do not do any AGP/Android Gradle Plugin upgrades when you open the project in Android Studio). The Android Studio project can be found at /platforms/android

Then you can dump the logcat as a text file here and when I find a chance I can look over it.

I have noticed that the app has not requested access to (listed with access to) Camera in the device settings.

CAMERA permission is not normally required unless if you're using the camera APIs directly, which this plugin does not. It delegates to the camera application installed on the device.

Normally the camera application contains the CAMERA permission so that they can operate the camera and send the result back to the requesting app. However there have been reports of camera applications not handling this correctly, and will not work unless if the application itself has the CAMERA permission. Which I'm beginning to think your case is this.

A workaround might be to declare the CAMERA permission at the app level.

So you can try adding the following in your config.xml:

...
<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/*" xmlns:android="http://schemas.android.com/apk/res/android">
        <uses-permission android:name="android.permission.CAMERA" />
    </config-file>
</platform>

The plugin does check if the CAMERA permission is declared and will request the permission if not granted. It's considered privacy sensitive so the CAMERA permission isn't declared automatically especially when it's normally not required. If this does solve your issue, it indicates a problem within the camera app itself.

@s5nicolay-dev
Copy link
Author

Thank you very much for your help. I have tried your suggestions. Unfortunately it does still not work, however maybe the logcat dump can provide some details? I noticed that after adding the config.xml change the app prompted for permission to record video.

Here is the logcat dump. Can you see any indication of what is going wrong?
Bluebird-EF551-Android-12_2024-10-31_095522.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants