My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 19857: LocationManager.requestLocationUpdates throws IllegalArgumentException: provider=network
42 people starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by gmd...@gmail.com, Sep 6, 2011
On an emulator running Google APIs 13, a call to

LocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, listener)

where listener is not null, causes the app to crash and the following exception:

09-06 22:46:16.163: ERROR/AndroidRuntime(351): Caused by: java.lang.IllegalArgumentException: provider=network
09-06 22:46:16.163: ERROR/AndroidRuntime(351):     at android.os.Parcel.readException(Parcel.java:1325)
09-06 22:46:16.163: ERROR/AndroidRuntime(351):     at android.os.Parcel.readException(Parcel.java:1275)
09-06 22:46:16.163: ERROR/AndroidRuntime(351):     at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
09-06 22:46:16.163: ERROR/AndroidRuntime(351):     at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
09-06 22:46:16.163: ERROR/AndroidRuntime(351):     at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)

This happens when "Use wireless networks" under "Location & security" is enabled or disabled.

This does not happen on the emulator up to API 10.

The API docs say:

"IllegalArgumentException 	if provider or listener is null"

Neither provider nor listener are null, and the provider even exists.

So the IllegalArgumentException thrown is unexpected and not consistent with the API docs.
Oct 19, 2011
#1 yukuku
Agree with you. Android developer docs reallllllyy needs more words to describe the API.
Nov 7, 2011
#4 kalyan.akella@gmail.com
This issue occurs even on an emulator running Google API Level 14, platform 4.0.

Here's the stacktrace...

11-08 08:36:25.885: E/AndroidRuntime(526): Caused by: java.lang.IllegalArgumentException: provider=network
11-08 08:36:25.885: E/AndroidRuntime(526): 	at android.os.Parcel.readException(Parcel.java:1331)
11-08 08:36:25.885: E/AndroidRuntime(526): 	at android.os.Parcel.readException(Parcel.java:1281)
11-08 08:36:25.885: E/AndroidRuntime(526): 	at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
11-08 08:36:25.885: E/AndroidRuntime(526): 	at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
11-08 08:36:25.885: E/AndroidRuntime(526): 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)

And the API docs for this method do not specify this behavior.
Dec 6, 2011
#5 fredd...@gmail.com
Confirmed on emulator running Google API Level 14, platform 4.0.
Application built using minSdkVersion="5" and android:targetSdkVersion="8".

Stacktrace:

Caused by: java.lang.IllegalArgumentException: provider=network
at android.os.Parcel.readException(Parcel.java:1331)
at android.os.Parcel.readException(Parcel.java:1281)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)
at com.mobileinteraction.android.indiska.StoreLocator.onResume(StoreLocator.java:68)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
at android.app.Activity.performResume(Activity.java:4539)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2433)

Jan 5, 2012
#6 Marc.DeR...@gmail.com
I am also seeing this for the gps provider as well. The failure is occasional; the location update requests initiate from the activities onResume function.

Caused by: java.lang.IllegalArgumentException: provider=gps
at android.os.Parcel.readException(Parcel.java:1326)
at android.os.Parcel.readException(Parcel.java:1276)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)
at com.myapp.location.UserLocation.resumeLocationServices(UserLocation.java:20)
at com.myapp.activities.SearchScreen.onResume(SearchScreen.java:1140)

Feb 14, 2012
#7 wwub...@gmail.com
Same here and repeatedly for app https://market.android.com/details?id=com.roundere

java.lang.IllegalArgumentException: provider=network
at android.os.Parcel.readException(Parcel.java:1331)
at android.os.Parcel.readException(Parcel.java:1281)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
at android.location.LocationManager._requestLocationUpdates(LocationManager.java:582)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:446)
at com.roundere.core.CoreService$2.run(CoreService.java:124)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at com.roundere.core.CoreService.run(CoreService.java:723)
at java.lang.Thread.run(Thread.java:856)
Apr 17, 2012
#8 christop...@gmail.com
Is there a work around or fix for this?
Apr 18, 2012
#9 eyaltg...@gmail.com
it seems like the NetworkManagerServer implmenetation is looking for a string with ref: config_networkLocationProvider which is: com.google.android.location.NetworkLocationProvider, i can't find any file by that name in the source code, that must be the reson, there's no implementation, most likly th implementation from older versions wont work, but it could be a good starting point.

any time defined to fix this bug ?
Apr 26, 2012
#10 marco.de...@gmail.com
sygic and api 15 and 16 cause the same stack trace:

E/AndroidRuntime(11498): FATAL EXCEPTION: main
E/AndroidRuntime(11498): java.lang.IllegalArgumentException: provider=gps
E/AndroidRuntime(11498): 	at android.os.Parcel.readException(Parcel.java:1331)
E/AndroidRuntime(11498): 	at android.os.Parcel.readException(Parcel.java:1281)
E/AndroidRuntime(11498): 	at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:646)
E/AndroidRuntime(11498): 	at android.location.LocationManager._requestLocationUpdates(LocationManager.java:589)
E/AndroidRuntime(11498): 	at android.location.LocationManager.requestLocationUpdates(LocationManager.java:453)
E/AndroidRuntime(11498): 	at com.sygic.aura.LocationServices_2x.startLocationManager(LocationServices.java:164)
E/AndroidRuntime(11498): 	at com.sygic.aura.LocationServices.startLocationManager(LocationServices.java:69)
E/AndroidRuntime(11498): 	at com.sygic.aura.SygicNaviActivity$1.handleMessage(SygicNaviActivity.java:177)
E/AndroidRuntime(11498): 	at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(11498): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(11498): 	at android.app.ActivityThread.main(ActivityThread.java:4428)
E/AndroidRuntime(11498): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11498): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(11498): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(11498): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(11498): 	at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  130):   Force finishing activity com.sygic.aura/.SygicNaviActivity
Apr 26, 2012
#11 tr...@euedge.com
Do not use direct provider strings, as it is not guaranteed that it will exist at runtime.

Use only providers that you get from the LocationManager, like this:


		LocationManager locationManager = (LocationManager)context.getSystemService( Context.LOCATION_SERVICE );
		
		Criteria criteria = new Criteria();
		criteria.setAccuracy( Criteria.ACCURACY_COARSE );
		String provider = locationManager.getBestProvider( criteria, true );
		
		if ( provider == null ) {
			Log.e( TAG, "No location provider found!" );
			return;
		}

		lastLocation = locationManager.getLastKnownLocation(provider);

Apr 26, 2012
#12 tr...@euedge.com
Another useful method in locationmanager is LocationManager.getAllProviders()

    /**
     * Returns a list of the names of all known location providers.  All
     * providers are returned, including ones that are not permitted to be
     * accessed by the calling activity or are currently disabled.
     *
     * @return list of Strings containing names of the providers
     */

May 29, 2012
#13 mc.k...@gmail.com
Is there a way out/work around, in case I only want to use LocationManager.NETWORK_PROVIDER?
Jul 31, 2012
#15 vp2177
Query providers for COARSE accuracy, if it is not the NETWORK one (usually it will be), then don't use it.
Jul 31, 2012
#16 tr...@euedge.com
You can simply _try_ it with some method and either you succeed or _catch_ the IllegalArgumentException and then you know that it is not available...

For example:

try {
    getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
catch( IllegalArgumentException e ) {
    // It is not available, abort whatever you wanted to do
    return;
}
// You can safely continue here, as we've verified that it works
Mar 15, 2013
#17 deugah...@gmail.com
Hi sirs,
Excuse me!
Here comes another question:
If we already know our NETWORK_PROVIDER does not exist, how we can enable it !?
Is it configured in the files or build flags?

Or the NETWORK_PROVIDER is included in the GMS package.
Those Android devices without GMS could not leverage this !?

Very much appreciated,
Gahong
Apr 16, 2013
#18 jmngo...@gmail.com
Is there a fix for this already?

Aug 9, 2013
#19 ga...@hz.cn
It has hanppen to me...
Sign in to add a comment

Powered by Google Project Hosting