Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
360 views
in Technique[技术] by (71.8m points)

android - Correct handling of exception: "getParameters failed (empty parameters)"

I have a camera app in the Google Play store with Google Analytics installed. I keep getting the following crash report:

getParameters failed (empty parameters)

My question is: What is the correct way to handle this?

Looking into the Android source of where it happens didn't give me any extra details. The error is thrown in android_hardware_Camera.cpp:

String8 params8 = camera->getParameters();
if (params8.isEmpty()) {
    jniThrowRuntimeException(env, "getParameters failed (empty parameters)");
    return 0;
}

Looking into open source Android camera to see how it handles the situation was also not very helpful. That code doesn't appear to catch the RuntimeException when calling getParameters. (Except in one case where they catch it, close the camera, then rethrow it).

Is there a correct way to handle this?

If not, is there a reason this happens so often?

Note: On any given day I have between 5k - 8k active users. With somewhere between 40-70 of these exceptions. That seems really high to me. I know there are legit instances where a camera may fail to initialize. But 1% of users seems unreasonable. Also, since the Android camera app doesn't handle the exception it really makes me wonder if there is some other root cause.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In my case I was getting this error :

getParameters failed (empty parameters)

when I called getParameters() after unlocking the camera. So, please call getParameters() before you call camera.unlock().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...