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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…