最近我发布了对我的Android应用(GitHubRepo)的更新,并且我已经开始通过Play商店从用户接收错误报告。我正在尝试排除故障,但我无法准确跟踪错误的含义。无法重现NumberFormatException
以下是报告的样子:
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));
}
有没有人有任何提示,如果我似乎无法重现我的设备上的错误如何进行?该应用程序严重依赖于用户输入数字,甚至在我的领域尝试了各种'凌乱'的数字(我尝试了一些非常长的数字)后,它对我来说完美无瑕。
你将重现它,当你改变手机的语言'German' –
你有NumberFormatException异常。你是否对其他输入进行了测试,而不是像字符这样的数字? –
这个double,你得到的形式可以是'2,25',因为','在某些国家正在使用。 –