camerakit-android icon indicating copy to clipboard operation
camerakit-android copied to clipboard

CaptureImage doesn't work most of the time on android

Open Tsabary opened this issue 6 years ago • 39 comments

Is this a bug report?

(write your answer here) Yes

Have you read the Contributing Guidelines?

Yes (Write your answer here.)

Environment

Android Studio emulator / OnePlus 5t

Steps to Reproduce

(Write your steps here:)

  1. Implement captureImage
  2. Try to take a photo

Expected Behavior

(Write what you thought would happen.)

A photo would be taken

Actual Behavior

(Write what happened. Add screenshots!)

The action doesn't kick in at all. I've entered a few Logs, the first being immedietly after calling to capture image, but whenever that issue exists (which is almost always for me both at the emulator and OnePlus device, that Log never prints.

Reproducible Demo

https://stackoverflow.com/questions/55526362/capture-image-action-only-works-sometimes-without-clear-reason-why

You could see here the relevant part of the code. The log that should print "image captured" almost never prints (and a photo isn't taken). When a photo is taken, the log of course prints, but there is no reasoning behind when it would or wouldn't work. It seems that it is more likely to work on the emulator.

Tsabary avatar Apr 09 '19 05:04 Tsabary

I've the same problem and have noticed it would take a picture if I obstruct the lens with for instance my finger.

drogeek avatar Apr 17 '19 13:04 drogeek

It wouldn't be a good solution, but it doens't work for me anyway. I've been pushing this fix to the end because I really want to avoid changing to Fotoapparat (moved it from there to CameraKit before), but looks like I'll have to. Really hoping for an update soon that'll fix it.

Tsabary avatar Apr 18 '19 10:04 Tsabary

Yes, noticing the same...CaptureImage doesnt do anything at least on 1.0.0-beta3.11'

Akshshr avatar Apr 18 '19 11:04 Akshshr

is there a previous version in which you know it did work? I don't mind downgrading for now, my camera request is super simple

Tsabary avatar Apr 18 '19 11:04 Tsabary

Experiencing same problem. Anyone have forced CameraKit work properly?

@Tsabary I also moved from Fotoapparat to CameraKit in hope it will work. (Fotoapparat seems doesn't work on API 17)

arsenii-repository avatar Apr 18 '19 17:04 arsenii-repository

Hey guys, can you be more specific about the versions of CK you are using? This isn't a known widespread issue but obviously is affecting you. We will look into it once we know more!

austinkettner avatar Apr 18 '19 17:04 austinkettner

build.gradle

    implementation 'com.camerakit:camerakit:1.0.0-beta3.11'
    implementation 'com.camerakit:jpegkit:0.1.0'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'

Also no errors/info in logcat. No error in CameraKitView.ErrorListener.

arsenii-repository avatar Apr 18 '19 17:04 arsenii-repository

Here are my details Gradle

 implementation 'com.camerakit:camerakit:1.0.0-beta3.10'
    implementation 'com.camerakit:jpegkit:0.1.0'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'

I think the root of a lot of these issues are that the sample app has very deprecated code. Would be nice to have that on V1

Akshshr avatar Apr 18 '19 17:04 Akshshr

I am using 3.11 now but the problem still existed when i was on 3.10.

I am running my app on the emulator and on a OnePlus 5t.

This is how my code is structured:

 captureButton.setOnClickListener {

        Log.d("photoActivity", "button clicked")

        cameraKitView.captureImage(){ _, p1 ->
            Log.d("photoActivity", "image captured")
    }
}

I've also tried instead of captureImage() to have it captureImage or captureFrame. The current setp seems to be the most consistent and I was just able to make it work with my OnePlus as well (literally for the first time as I was writing this) but it is still not consistent.

button clicked is always printed, where image captured almost never does (it rarely happens and inly on the emulator).

Tsabary avatar Apr 18 '19 20:04 Tsabary

Update: as per Murphy's law, things might actually be working for me now. It seems to be more consistent after I've added the empty brackets. I am still running tests but it is deffinitely working much better than it did before.

Tsabary avatar Apr 18 '19 20:04 Tsabary

Update: it stops working again. I can't get it to be stable. Before calling it an issue, I think it would be best if you can provide with the proper way to capture an image using Kotlin, because currently I can't tell if it is nor consistent because of the library or because I am doing something wrong (though I have tried quit a few different options)

Tsabary avatar Apr 26 '19 04:04 Tsabary

I was trying to debug this, but Android Studio claimed that the bytecode didn't match the source code for CameraKitView, so I've cloned branch v1.0.0-beta4, added the camerakit directory to my project and, with some effort, made it build as a subproject just like the demo app does in this repository instead of using the pre-built release.

Good news: with the integrated project this works. So my guess is that the published build is out of date.

I'm not sure I'd be able to tell you how I did the subproject integration, as it was quite a bit of trial and error (I'm new to Android development), using the gradle files in this repository as reference each time I had an error.

Uplink03 avatar Apr 27 '19 04:04 Uplink03

Same problem here in my Google Pixel 1. I have implemented the captureImage function as instructed and Logcat didn't print anything strange...and that's strange hhhh.

leokvw avatar May 06 '19 09:05 leokvw

Same problem

gabrielbatta avatar May 06 '19 19:05 gabrielbatta

same problem

tycallen avatar May 07 '19 11:05 tycallen

Any insights? Dealing with this too...

wintermoon9 avatar May 07 '19 16:05 wintermoon9

same problem, only with 3.11

fireb86 avatar May 08 '19 08:05 fireb86

Here is what I have found while testing on some devices: Moto G4+:

  • No image can be captured
  • toggleCamera() fails

Xiaomi Mi A10:

  • TODO: I will update this within 24 hours.

OnePlus 6:

  • Low light results in no image capture and toggleCamera() method doesn't work
  • Proper lighting leads to one successful image capture however subsequent image callbacks are never triggered. The same happens with toggleCamera() method.
  • When the device is placed on a flat surface then any number of photos can be captured. toggleCamera() works each time.

chintan-mishra avatar May 11 '19 04:05 chintan-mishra

same problem, SM-G935FD

PORTB avatar May 12 '19 04:05 PORTB

same problem here on Samsung Device ( Tab Active 2)

FelipeBerrios avatar May 15 '19 18:05 FelipeBerrios

Surprisingly enough, adding an errorListener to the CameraKitView has fixed the problem.

DarkMinstrel avatar Jun 07 '19 08:06 DarkMinstrel

@DarkMinstrel it doesn't seem to work for some devices.

chintan-mishra avatar Jun 10 '19 07:06 chintan-mishra

I have the same Problem. Sometimes it work. But most of the time it doesn't work.

Intonjokel avatar Jun 13 '19 09:06 Intonjokel

Same problem here

Jaime97 avatar Jun 27 '19 09:06 Jaime97

Same problem, from MI 6(Android 8.0)

toeii avatar Aug 23 '19 02:08 toeii

Same problem, from MI 6(Android 8.0)

This problem can be avoided by lowering the version to v1.0.0-beta3.10

toeii avatar Aug 23 '19 02:08 toeii

same problem from oneplus3A and oneplus6

simplepeng avatar Oct 09 '19 05:10 simplepeng

the same problem

nxnyk avatar Oct 19 '19 05:10 nxnyk

same for me. beta3.11 Works sometimes, doesn't work sometimes. Built in a retry with stopping starting the camera again. Works sometimes, doesn't work sometimes. Is this project discontinued. The last change seemed to be happening months ago...

javdev avatar Nov 24 '19 21:11 javdev

and 3.10 same problem. I even cleaned the project, rebuilt it, invalidated the caches and restarted.

javdev avatar Nov 24 '19 22:11 javdev