com.backendless.BackendlessUser cannot be cast to java.util.HashMap

Hello Backendless team!

I checked other answers but didn’t realy understand how can I solve this problem. I am trying to keep the current user logged in after restarting the app but I get the error in the attached photo. I highlighted the relevant code snippet.

Regards,
Kasim

String userId = UserIdStorageFactory.instance().getStorage().get();

if (userId != null && !"".equals(userId)) {
    Backendless.UserService.findById(userId, new AsyncCallback<BackendlessUser>() {
        @Override
        public void handleResponse(BackendlessUser user) {
            Log.d("Main Activity", user.getEmail());
        }

        @Override
        public void handleFault(BackendlessFault fault) {
            Log.e("Main Activity", fault.getMessage());
        }
    });
}
FATAL EXCEPTION: main
	Process: com.kasimgul.talentpool, PID: 4212
	java.lang.ClassCastException: com.backendless.BackendlessUser cannot be cast to java.util.HashMap
	at com.backendless.UserService$6.handleResponse(UserService.java:546)
	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:98)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5417)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

userId is NOT null by the way.

Hi Kasim,

The code you wrote looks reasonable.

Could you please grab the latest build of our library and try with it:
https://github.com/Backendless/Android-SDK/blob/master/out/backendless.jar

if you get an exception, please post the complete stack trace.

Regards,
Mark

Hi Mark!

Thanks for quick reply. I have this line in my gradle file and nothing else. Where should I put this file?

compile 'com.backendless:android:1.16'

Hi Kasim,

You’re using a super old version of the library. Try changing it to this first and see if it works:

compile ‘com.backendless:backendless:3.0.8.2’
Regards,Mark

Thank you Mark!

I think you should place a new line with newest gradle version somewhere in the README.md on github :slight_smile:

Have a nice day!

Done - added it to README.md