2011-08-17 117 views
0

我与谷歌地图的工作。当我第一次运行我的应用程序时,它显示一个错误。我点击力量关闭和应用程序再次运行,第二次都很好。这是我的日志猫:安卓:ActivityThread.performLaunchActivity错误

08-17 07:06:35.288: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test' (No such file or directory) 
08-17 07:06:35.288: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test' (No such file or directory) 
08-17 07:06:35.288: ERROR/vold(26): Error opening switch name path '/sys/class/switch/test2' (No such file or directory) 
08-17 07:06:35.288: ERROR/vold(26): Error bootstrapping switch '/sys/class/switch/test2' (No such file or directory) 
08-17 07:06:43.888: ERROR/BatteryService(51): usbOnlinePath not found 
08-17 07:06:43.888: ERROR/BatteryService(51): batteryVoltagePath not found 
08-17 07:06:43.888: ERROR/BatteryService(51): batteryTemperaturePath not found 
08-17 07:06:43.908: ERROR/SurfaceFlinger(51): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 
08-17 07:06:47.309: ERROR/EventHub(51): could not get driver version for /dev/input/mouse0, Not a typewriter 
08-17 07:06:47.309: ERROR/EventHub(51): could not get driver version for /dev/input/mice, Not a typewriter 
08-17 07:06:47.539: ERROR/System(51): Failure starting core service 
08-17 07:06:47.539: ERROR/System(51): java.lang.SecurityException 
08-17 07:06:47.539: ERROR/System(51):  at android.os.BinderProxy.transact(Native Method) 
08-17 07:06:47.539: ERROR/System(51):  at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146) 
08-17 07:06:47.539: ERROR/System(51):  at android.os.ServiceManager.addService(ServiceManager.java:72) 
08-17 07:06:47.539: ERROR/System(51):  at com.android.server.ServerThread.run(SystemServer.java:176) 
08-17 07:06:47.548: ERROR/AndroidRuntime(51): Crash logging skipped, no checkin service 
08-17 07:06:52.005: ERROR/ActivityThread(93): Failed to find provider info for android.server.checkin 
08-17 07:06:52.905: ERROR/ActivityThread(93): Failed to find provider info for android.server.checkin 
08-17 07:06:52.974: ERROR/ActivityThread(93): Failed to find provider info for android.server.checkin 
08-17 07:06:54.728: ERROR/vold(26): Cannot start volume '/sdcard' (volume is not bound) 
08-17 07:06:54.934: ERROR/MediaPlayerService(30): Couldn't open fd for content://settings/system/notification_sound 
08-17 07:06:54.944: ERROR/MediaPlayer(51): Unable to to create media player 
08-17 07:06:57.375: ERROR/ActivityThread(51): Failed to find provider info for com.google.settings 
08-17 07:06:57.375: ERROR/ActivityThread(51): Failed to find provider info for com.google.settings 
08-17 07:07:00.225: ERROR/AndroidRuntime(207): ERROR: thread attach failed 
08-17 07:07:01.955: ERROR/AndroidRuntime(220): ERROR: thread attach failed 
08-17 07:07:07.805: ERROR/ActivityThread(233): Failed to find provider info for com.google.settings 
08-17 07:07:07.805: ERROR/ActivityThread(233): Failed to find provider info for com.google.settings 
08-17 07:07:07.885: ERROR/ActivityThread(233): Failed to find provider info for com.google.settings 
08-17 07:07:08.265: ERROR/AndroidRuntime(233): Uncaught handler: thread main exiting due to uncaught exception 
08-17 07:07:08.275: ERROR/AndroidRuntime(233): java.lang.RuntimeException: Unable to start activity ComponentInfo{test.projekat/test.projekat.TrenutnaLokacija}: java.lang.NullPointerException 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.ActivityThread.access$2200(ActivityThread.java:119) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.os.Handler.dispatchMessage(Handler.java:99) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.os.Looper.loop(Looper.java:123) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.ActivityThread.main(ActivityThread.java:4363) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at java.lang.reflect.Method.invokeNative(Native Method) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at java.lang.reflect.Method.invoke(Method.java:521) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at dalvik.system.NativeStart.main(Native Method) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233): Caused by: java.lang.NullPointerException 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at test.projekat.TrenutnaLokacija.onCreate(TrenutnaLokacija.java:91) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 
08-17 07:07:08.275: ERROR/AndroidRuntime(233):  ... 11 more 

我的问题是:

08-17 07:07:08.275: ERROR/AndroidRuntime(233): Caused by: java.lang.NullPointerException 
    08-17 07:07:08.275: ERROR/AndroidRuntime(233):  at test.projekat.TrenutnaLokacija.onCreate(TrenutnaLokacija.java:90) 

firstDot = new GeoPoint((int) (location.getLatitude()*1E6),(int) (location.getLongitude()*1E6)); 

我编辑的问题......这是我的代码...位置是null..I开始我的应用程序在Android手机上和它不工作...

public void onCreate(Bundle savedInstance){ 
     super.onCreate(savedInstance); 
     setContentView(R.layout.pocetna); 

     mapView = (MapView) findViewById(R.id.mapview);  
     textView = (TextView) findViewById(R.id.text1);  
     textView3 = (TextView) findViewById(R.id.textView2); 
     mapController = mapView.getController(); 
     mapController.setZoom(17);  
     mapView.setStreetView(true); 
     mapView.setBuiltInZoomControls(true); 
     button = (Button) findViewById(R.id.button1); 
     //mapView.setSatellite(true);  
     sb = (SeekBar) findViewById(R.id.seekBar1); 

     locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 

     locationListener = new LocationListener() { 

      @Override 
      public void onStatusChanged(String provider, int status, Bundle extras) { 

      } 

      @Override 
      public void onProviderEnabled(String provider) {     

      } 

      @Override 
      public void onProviderDisabled(String provider) { 
       updateWithNewLocation(null); 

      } 

      @Override 
      public void onLocationChanged(Location location) {    
//    TrenutnaLokacija.this.location = location; 
       updateWithNewLocation(location);  

      } 
     }; 

     Criteria criteria = new Criteria(); 
     criteria.setPowerRequirement(Criteria.POWER_LOW); 
     criteria.setAccuracy(Criteria.ACCURACY_FINE); 
     provider = locationManager.getBestProvider(criteria, true); 

     locationManager.requestLocationUpdates(provider, 0, 0, locationListener); 


     try{ 
      location = locationManager.getLastKnownLocation(provider); 

     }catch (IllegalArgumentException e) { 
      Log.d("location", "Greska", e); 
     }catch (SecurityException s) { 
      Log.d("dsds", "Greska", s); 
     } 

     AlertDialog ad1 = new AlertDialog.Builder(this).create(); 
     ad1.setTitle("Greska"); 
     ad1.setMessage("Trenutno nisu ucitane lokacije"); 
     ad1.setButton(DialogInterface.BUTTON_POSITIVE, "Dozvoli", new DialogInterface.OnClickListener() { 

      @Override 
      public void onClick(DialogInterface ad, int which) { 

      } 
     }); 

     if(location == null){ 
      ad1.show(); 
      Intent i = new Intent(TrenutnaLokacija.this, PronadjiKlopuActivity.class); 
      startActivity(i); 
     } 



     GeoPoint firstDot = new GeoPoint((int) (location.getLatitude()*1E6),(int) (location.getLongitude()*1E6)); 

     myPosition = new NewItemizedOverlay(getResources().getDrawable(R.drawable.map_pin), firstDot); 
     listOfOverlays = mapView.getOverlays(); 
     listOfOverlays.clear(); 
     listOfOverlays.add(myPosition); 
+0

嗨,请用你的onCreate方法编辑你的问题。在你的班级TrenutnaLokacija.java有问题:在第91行,你可以在错误日志中看到。 – milind

+0

@milind感谢的人 – Jovan

回答

0

你必须在TrenutnaLokacija类空指针异常上线91

这是乌苏当你还没有实例化一个变量时,或者你正在从共享首选项或其他类调用中检索时,如果找不到你指定的内容,它将返回null。

http://www.javacoffeebreak.com/articles/toptenerrors.html请参阅1号!

编辑

因为你说它运行,这听起来像你想获得一个位置,但它不是在你的onCreate()尚未加载精细第二次

这是可能的位置是空这里:

location.getLatitude(); 
+0

第91行 - 如果我数它,我要从onCreate方法开始,我是我计数和评论,我做了? – Jovan

+0

要打开行号在日食:窗口>首选项>常规>编辑>文本编辑器>显示行号复选框打钩,申请:) – Blundell

+0

我91行是空的空间... 90和92系列有: firstDot =新的GeoPoint ((int)(location.getLatitude()* 1E6),(int)(location.getLongitude()* 1E6)); \t \t \t \t myPosition = new NewItemizedOverlay(getResources()。getDrawable(R.drawable.map_pin),firstDot); – Jovan