Can not create BackendLessGeometry from type weborb.reader.CacheableAdaptingTypeWrapper

Hi,

I’m currently trying to receive/remove a LineString from my database once it is approved/disapproved and reflect that on my Android application, however every time I approve or disapprove my app crashes giving the error:

Application ID: 99C0754B-6B4E-417F-FF30-6281C4DFFB00

java.lang.RuntimeException: Can not create BackendlessGeometry from type weborb.reader.CacheableAdaptingTypeWrapper
                 	at com.backendless.persistence.BackendlessGeometryFactory.createObject(BackendlessGeometryFactory.java:61)
                 	at weborb.util.ObjectFactories._createArgumentObject(ObjectFactories.java:145)
                 	at weborb.util.ObjectFactories.createArgumentObject(ObjectFactories.java:132)
                 	at weborb.reader.AnonymousObject.getPropertyValue(AnonymousObject.java:501)
                 	at weborb.reader.AnonymousObject.setFieldsDirect(AnonymousObject.java:434)
                 	at weborb.reader.AnonymousObject.adaptToClass(AnonymousObject.java:291)
                 	at weborb.reader.AnonymousObject.adapt(AnonymousObject.java:140)
                 	at weborb.reader.AnonymousObject.adapt(AnonymousObject.java:134)
                 	at weborb.reader.CacheableAdaptingTypeWrapper.adapt(CacheableAdaptingTypeWrapper.java:47)
                 	at com.backendless.rt.data.EventHandlerImpl$5.handleResponse(EventHandlerImpl.java:499)
                 	at com.backendless.rt.data.EventHandlerImpl$5.handleResponse(EventHandlerImpl.java:487)
                 	at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
                 	at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
                 	at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
                 	at android.os.Handler.dispatchMessage(Handler.java:102)
                 	at android.os.Looper.loopOnce(Looper.java:226)
                 	at android.os.Looper.loop(Looper.java:313)
                 	at android.app.ActivityThread.main(ActivityThread.java:8757)
                 	at java.lang.reflect.Method.invoke(Native Method)
                 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

I’m confused as I am able to retrieve the LineStrings initially just fine, and I am also able to change other properties for that particular object, such as likes and have it reflect on the Android app just fine as well. Furthermore, I am also able to delete the object from Backendless.com and have it reflect on my application too.

I have two functions that are for the approval functionality here:

override suspend fun observeApproval(): Flow<PointSet> {
        return callbackFlow {
            Log.d("observeApproval", "here")
            val event = backendless.of(PointSet::class.java).rt()
            val callback = object : AsyncCallback<PointSet> {
                override fun handleResponse(response: PointSet) {
                    Log.d("observeApproval", response.toString())
                    trySendBlocking(response)
                }

                override fun handleFault(fault: BackendlessFault?) {
                    Log.d("observeApproval", fault.toString())
                    fault?.message?.let { cancel(message = it) }
                }
            }
            event.addUpdateListener("approved = false or approved = true", callback)
            awaitClose {
                event.removeUpdateListeners()
            }
        }
    }

and

   private fun observeApproval() { // Observes or "listens" to changes for a PointSet based on approval/disapproval
        viewModelScope.launch(Dispatchers.IO) {
            repository.observeApproval().collect { set ->
                Log.d("observeApproval", "${set.points.toString()}")
                if (set.approved) {
                    pointSets.add(set)
                } else {
                    pointSets.removeAll {
                        it.objectId == set.objectId
                    }
                }
            }
        }
    }

Any help or explanation would be appreciated! Thank you!

Hello @Kayin_Ilagan,

I have created an internal ticket for this issue. Once we have any update on it, you will be informed about it here in this thread.

Regards,
Stanislaw

Update:

I managed to fix the issue! It turns out that when I receive the PointSet object from Backendless, the collection automatically unmaps it for me, however when trying to access my ‘points’ property of the PointSet object, the object itself is still a hashmap. The hashmap contains information needed to be identified as a LineString, however Android’s compiler cannot cast it as LineString. In order to fix it, I had to access the hashmap’s coordinates key and cast the associated value Array. Once casted, every element of that array is also casted as an Array which allowed me to access the Double values of the X and Y coordinates and create the LineString object manually in Android.

Hope this helps anyone!

Best,
Kayin