Android程序在Froyo上崩溃,但在Kitkat上没有崩溃

时间:2014-03-22 22:50:03

标签: android logcat android-2.2-froyo android-4.4-kitkat

我正在为Android创建一个天气应用程序。该应用程序使用Wifi and Network提供程序来获取位置。该程序有时运行没有任何错误。大多数情况下,我关闭设备并再次运行它,但如果我在成功运行后立即从eclipse运行它,则会出现上述错误。

该应用在Android版4.4.2上运行,但在Android 2.2上崩溃。

最低SDK版本为8,符合Froyo

Logcat警告和错误:

03-22 23:41:48.471: W/dalvikvm(7332): threadid=1: thread exiting with uncaught exception (group=0x4001d7d0)
03-22 23:41:48.538: E/AndroidRuntime(7332): FATAL EXCEPTION: main
03-22 23:41:48.538: E/AndroidRuntime(7332): java.lang.NumberFormatException: unable to parse '' as integer
03-22 23:41:48.538: E/AndroidRuntime(7332):     at java.lang.Integer.parseInt(Integer.java:412)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at java.lang.Integer.parseInt(Integer.java:382)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at com.dobbymon.rainguard.MainActivity$AsyncCaller.onPostExecute(MainActivity.java:549)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at com.dobbymon.rainguard.MainActivity$AsyncCaller.onPostExecute(MainActivity.java:1)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at android.os.AsyncTask.finish(AsyncTask.java:417)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at android.os.Looper.loop(Looper.java:123)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at java.lang.reflect.Method.invokeNative(Native Method)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at java.lang.reflect.Method.invoke(Method.java:521)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:871)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
03-22 23:41:48.538: E/AndroidRuntime(7332):     at dalvik.system.NativeStart.main(Native Method)

可能的错误代码:

int gb=0;

                  String geocode="";
                      try {


                          geocode = new Scanner(new URL("http://freegeoip.net/xml/").openStream(), "UTF-8").useDelimiter("\\A").next();
                     System.out.println("geocode ="+geocode);
                      gb=geocode.length();
                      System.out.println("gb= "+gb);
                      } catch (Exception e) {


                      }

                      InputSource source2 = new InputSource(new StringReader(geocode));

                      try{
                       nameofplace = xpath.evaluate("/Response/City", source2);

                       System.out.println("nameofplace ="+nameofplace);

                      }
                      catch (Exception e) {
                      e.printStackTrace();
                                  }

0 个答案:

没有答案