2012-09-21 40 views
2

我將我的應用程序發佈到了android市場。我的主頁出錯了。有人寫了崩潰錯誤。但是這個應用程序在我的真實設備中完美工作。我也添加了權限。 我的錯誤:關於java.lang.IllegalArgumentException的錯誤:provider == null

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.karthi.locationspeecher/com.android.locationspeecher.LocationSpeecher}: java.lang.IllegalArgumentException: provider==null 
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.IllegalArgumentException: provider==null 
at android.location.LocationManager.getLastKnownLocation(LocationManager.java:1017) 
at com.android.locationspeecher.LocationSpeecher.onCreate(LocationSpeecher.java:84) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615) 
... 11 more 

的LocationManager:

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

      Criteria crta = new Criteria(); 
      crta.setAccuracy(Criteria.ACCURACY_FINE); 
      crta.setAltitudeRequired(false); 
      crta.setBearingRequired(false); 
      crta.setCostAllowed(true); 
      crta.setPowerRequirement(Criteria.POWER_LOW); 
      String provider = locationManager.getBestProvider(crta, true); 

     // String provider = LocationManager.GPS_PROVIDER; 
      Location location = locationManager.getLastKnownLocation(provider); 
      updateWithNewLocation(location); 

      locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); 
      } 

回答

6

你最有可能得到這個錯誤,由於未GPS Providers可用性。如果Gps ProviderNetwork Provider已啓用進入位置設置,請要求該人檢查設置。

0

此外請確保將android.permission.ACCESS_FINE_LOCATIONandroid.permission.ACCESS_COARSE_LOCATION添加到您的Manifest文件中,這爲我解決了問題(所有提供程序都已在位置設置中啓用)。

`[組件:UsesPermission(Manifest.Permission.AccessFineLocation)] [組件:UsesPermission(Manifest.Permission.AccessCoarseLocation)] [組件:UsesPermission(Manifest.Permission

0

我通過添加解決了這個。互聯網)]'

在assemlyInfo.cs中給予許可

相關問題