最近我发布了我的 Android 应用程序(GitHubRepo)的更新,并且我已经开始通过 Play 商店从用户那里收到错误报告。我正在尝试进行故障排除,但我无法准确追踪错误的含义。
以下是报告的样子:
java.lang.RuntimeException: Unable to start activity ComponentInfo{ca.ajwest.BeerConverter/ca.ajwest.BeerConverter.BeerConverterActivity}: java.lang.NumberFormatException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NumberFormatException
at org.apache.harmony.luni.util.FloatingPointParser.parseDblImpl(Native Method)
at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:283)
at java.lang.Double.parseDouble(Double.java:318)
at java.lang.Double.valueOf(Double.java:356)
at ca.ajwest.BeerConverter.BeerConverterActivity.roundTwoDecimals(BeerConverterActivity.java:1513)
at ca.ajwest.BeerConverter.BeerConverterActivity.calculate(BeerConverterActivity.java:987)
at ca.ajwest.BeerConverter.BeerConverterActivity.access$0(BeerConverterActivity.java:757)
at ca.ajwest.BeerConverter.BeerConverterActivity$21.onTextChanged(BeerConverterActivity.java:469)
at android.widget.TextView.sendOnTextChanged(TextView.java:6584)
at android.widget.TextView.setText(TextView.java:2813)
at android.widget.TextView.setText(TextView.java:2671)
at android.widget.EditText.setText(EditText.java:178)
at ca.ajwest.BeerConverter.BeerConverterActivity.onCreate(BeerConverterActivity.java:541)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 11 more
我是否正确假设它与我的舍入方法舍入的值有关?
double roundTwoDecimals(double d){
DecimalFormat twoDForm = new DecimalFormat("#.##");
return Double.valueOf(twoDForm.format(d));
}
当我似乎无法在我的设备上重现错误时,是否有人对如何进行操作有任何提示?该应用程序严重依赖用户输入数字,即使在我的领域中尝试了各种“凌乱”的数字(我已经尝试了一些非常长的数字),它对我来说仍然完美无缺。