fjlopezs / little-fluffy-location-library

Automatically exported from code.google.com/p/little-fluffy-location-library
0 stars 0 forks source link

null pointer Exception from LocationBroadcastService -> gms #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
"java.lang.NullPointerException
        at com.google.android.gms.internal.ea.f(Unknown Source)
        at com.littlefluffytoys.littlefluffylocationlibrary.LocationBroadcastService.a(LocationBroadcastService.java:295)
        at com.google.android.gms.internal.dy.handleMessage(Unknown Source)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4747)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
"

Code is ProGuard optimised.

Original issue reported on code.google.com by syt...@gmail.com on 18 Jun 2014 at 12:51

GoogleCodeExporter commented 9 years ago
this Exception is with v17

Original comment by syt...@gmail.com on 18 Jun 2014 at 12:52

GoogleCodeExporter commented 9 years ago
I have check in LocationBroadcastService line 295 is 
mLocationClient.disconnect();

maybe this will fix gms nullPointer:

try {
            mLocationClient.disconnect();
        } catch (Exception e){
            Log.e(LocationLibraryConstants.TAG, TAG + ": onLocationChanged: " + e.getMessage());
        }

Original comment by syt...@gmail.com on 18 Jun 2014 at 1:01

GoogleCodeExporter commented 9 years ago
And in LocationLibrary too:

public void onConnected(Bundle arg0)
    {
        if (mLocationClient != null) {
            final Location mCurrentLocation = mLocationClient.getLastLocation();
            try {
                mLocationClient.disconnect();
            } catch (Exception e){
                Log.e(LocationLibraryConstants.TAG, TAG + ": onConnected: " + e.getMessage());
            }
            if (mCurrentLocation != null) {
                if (LocationLibrary.showDebugOutput) Log.d(TAG, "Last location lat=" + mCurrentLocation.getLatitude() + " long=" + mCurrentLocation.getLongitude());
                PassiveLocationChangedReceiver.processLocation(mContext, mCurrentLocation, false, false);
            }
        }
    }

Original comment by syt...@gmail.com on 18 Jun 2014 at 1:04

GoogleCodeExporter commented 9 years ago
java.lang.IllegalStateException: Trying to unbind a GmsServiceConnection  that 
was not bound before.  
startServiceAction=com.google.android.location.internal.GoogleLocationManagerSer
vice.START
        at com.google.android.gms.internal.bs.b(Unknown Source)
        at com.google.android.gms.internal.bh.c(Unknown Source)
        at com.littlefluffytoys.littlefluffylocationlibrary.LocationBroadcastService.c(LocationBroadcastService.java:172)
        at com.littlefluffytoys.littlefluffylocationlibrary.LocationBroadcastService$1.run(LocationBroadcastService.java:120)
        at java.lang.Thread.run(Thread.java:856)

An other error is appear after try catch.
Maybe this check before disconnect can replace try catch:

if(mLocationClient.isConnected())

Original comment by syt...@gmail.com on 18 Jun 2014 at 1:47

GoogleCodeExporter commented 9 years ago
Please supply details of your device, Android version, any mods, etc.

Original comment by ken...@kentonprice.com on 19 Jun 2014 at 8:16

GoogleCodeExporter commented 9 years ago
Tablet Asus ME371MG Android: 4.1.2

I have use ACRA and this is part from the log file:

06-18 16:17:46.226 E/GmsClient(22645): Calling connect() while still connected, 
missing disconnect().
06-18 16:17:46.236 E/GmsClient(22645): Calling connect() while still connected, 
missing disconnect().

I have add if(!mLocationClient.isConnected()) before all connect() and this 
error disappear.

Original comment by syt...@gmail.com on 19 Jun 2014 at 11:14

GoogleCodeExporter commented 9 years ago
Thanks for that. I'll implement it soon. I really should move this to Github so 
I can accept pull requests :-)

Original comment by ken...@kentonprice.com on 19 Jun 2014 at 11:42

GoogleCodeExporter commented 9 years ago
Yes move to github is good idea ;)

Original comment by syt...@gmail.com on 19 Jun 2014 at 2:41