2

I have an error like this:

02-03 16:41:18.294 994-1830/? E/Parcel: Class not found when unmarshalling: com.google.android.gms.location.LocationResult
                                    java.lang.ClassNotFoundException: com.google.android.gms.location.LocationResult
                                        at java.lang.Class.classForName(Native Method)
                                        at java.lang.Class.forName(Class.java:309)
                                        at java.lang.Class.forName(Class.java:273)
                                        at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
                                        at android.os.Parcel.readParcelable(Parcel.java:2245)
                                        at android.os.Parcel.readValue(Parcel.java:2152)
                                        at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
                                        at android.os.BaseBundle.unparcel(BaseBundle.java:221)
                                        at android.os.BaseBundle.containsKey(BaseBundle.java:269)
                                        at android.content.Intent.hasExtra(Intent.java:4924)
                                        at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:398)
                                        at com.android.server.am.a.startServiceLocked(Unknown Source)
                                        at com.android.server.am.ActivityManagerService.startServiceInPackage(ActivityManagerService.java:15737)
                                        at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:324)
                                        at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:219)
                                        at android.content.IIntentSender$Stub.onTransact(IIntentSender.java:64)
                                        at android.os.Binder.execTransact(Binder.java:463)
                                     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.location.LocationResult" on path: DexPathList[[zip file "/system/framework/XposedBridge.jar"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
                                        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                        at java.lang.Class.classForName(Native Method) 
                                        at java.lang.Class.forName(Class.java:309) 
                                        at java.lang.Class.forName(Class.java:273) 
                                        at android.os.Parcel.readParcelableCreator(Parcel.java:2281) 
                                        at android.os.Parcel.readParcelable(Parcel.java:2245) 
                                        at android.os.Parcel.readValue(Parcel.java:2152) 
                                        at android.os.Parcel.readArrayMapInternal(Parcel.java:2485) 
                                        at android.os.BaseBundle.unparcel(BaseBundle.java:221) 
                                        at android.os.BaseBundle.containsKey(BaseBundle.java:269) 
                                        at android.content.Intent.hasExtra(Intent.java:4924) 
                                        at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:398) 
                                        at com.android.server.am.a.startServiceLocked(Unknown Source) 
                                        at com.android.server.am.ActivityManagerService.startServiceInPackage(ActivityManagerService.java:15737) 
                                        at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:324) 
                                        at com.android.server.am.PendingIntentRecord.send(PendingIntentRecord.java:219) 
                                        at android.content.IIntentSender$Stub.onTransact(IIntentSender.java:64) 
                                        at android.os.Binder.execTransact(Binder.java:463) 
                                        Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.location.LocationResult
                                        at java.lang.Class.classForName(Native Method)
                                        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                ... 18 more
                                     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

My gradle: build.gradle. My manifest:manifest. I am work on application that work with Location and have this error. I configure a multidex, but it is not help. What can be wrong?

Vikas Sardana
  • 1,593
  • 2
  • 18
  • 37
Kl0nLutiy
  • 31
  • 1
  • 3

2 Answers2

4

In my case i had solve this problem adding to build.gradle:

implementation 'com.google.android.gms:play-services-location:17.0.0'
Max Shwed
  • 232
  • 2
  • 10
2

I had the same issue. After a lot of debugging, I realised it was because I was adding my own extra's to the intent bundle.

I am creating a location request and specifying a pending intent to be fired when a location update is received in the background.

Intent myIntent = new Intent(context, MyIntentServiceClass.class); myIntent.putExtra("someString", "someValue");

PendingIntent pendingIntent = PendingIntent.getService(context, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);

LocationServices.FusedLocationApi.requestLocationUpdates(apiClient, request, pendingIntent);

The Intent Service is fired when the location is received. My own extra is inside the intent. But there isn't a location. I had exactly the same error as this in the logs.

As soon as I remove my own extra from the Intent, I receive the location and the error is gone.

I know from working with the google map api that there is similar challenges when you want to use a map object and also save your own items when saving and restoring from state. I can't find the link to the documentation right now, but it was something to the effect of the Bundle itself being parceled (thus losing its attached class loader). In order to work around it, you have to create your own bundle and store your internal objects in the new bundle. Then add the bundle to the out state.

I'm going to play around to see how I can still add my own extras to the location request bundle without affecting it as is happening here.

MacMc
  • 111
  • 5