Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 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 Reply

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().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...