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.


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

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

        public void handleFault(BackendlessFault fault) {
            Log.e("Main Activity", fault.getMessage());
	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(
	at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(
	at com.backendless.async.message.AsyncMessage.handleCallback(
	at com.backendless.core.AndroidCarrier$1.handleMessage(
	at android.os.Handler.dispatchMessage(
	at android.os.Looper.loop(
	at java.lang.reflect.Method.invoke(Native Method)

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:

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


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:’

Thank you Mark!

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

Have a nice day!

Done - added it to