java.util.HashMap cannot be cast to com.backendless.services.messagin

Hello Team Backendless,
I am facing problem while sending a push notification. Here attached is my code snippet in which I have written the code push notification. Kindly guide me so that I can come out of this project. Thanks in advance.
This code is written in button’s click listener so I have not copied that code here.
if(getValuesInStrings())
{
String userKey = Session_.emaill();
userKey = userKey.replace(’.’,’,’);
String uniqueKey = myRefUsers.child(userKey).child(“sentQuotes”).push().getKey();
Map<String, String> timeStamp = ServerValue.TIMESTAMP;
String tStamp = timeStamp.toString();
// String tStamp = “hammad”;

QuoteBo newQuote = new QuoteBo(userKey,strService,strDetails,strContacNo,strDate
,strTime,Latt,Long,uniqueKey,tStamp);
myRefUsers.child(userKey).child(“sentQuotes”).child(uniqueKey).setValue(newQuote);
myRefQuotes.child(uniqueKey).setValue(newQuote);
serviceSpinner.setSelection(0);
etContactNo.setText("");
etDetails.setText("");
PublishOptions publishOptions= new PublishOptions();
publishOptions.putHeader(“android-content-text”,“XYZ”);
publishOptions.putHeader(“android-content-title”,“ABC”);
publishOptions.putHeader(“android-ticker-text”,“dammah nassah”);
DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.addPushSinglecast(“0123456789ABCDEF”);
Backendless.Messaging.publish((Object) “kch bhe”, publishOptions, deliveryOptions,new AsyncCallback<MessageStatus>() {
@Override
public void handleResponse(MessageStatus response) {
Toast.makeText(QuoteRequest.this, “Notification Sent”, Toast.LENGTH_SHORT).show();
}
@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(QuoteRequest.this, “”+fault, Toast.LENGTH_SHORT).show();
}
});
}

A couple of questions for you:

    Is the problem with the error you have in the subject line?
    Which line reports the error?
    What version of the SDK do you use?
    What version of the backend do you use?

Answers:
1: Yes the error is what written in subject line.

2: This line reports the error “Backendless.Messaging.publish((Object) “kch bhe”, publishOptions, deliveryOptions,new AsyncCallback<MessageStatus>”
3: complied SKD is 25 and Build tool version is “25.0.2”
4: compile ‘com.backendless:android:3.0.25’

Could you please update to the latest version of the SDK (3.1.0) and try again?:

https://search.maven.org/#artifactdetails|com.backendless|android|3.1.0|jar

by changing the line “compile ‘com.backendless:android:3.0.25’” to " compile ‘com.backendless:android:3.1.0’"

I do not know how you build the project, but that would be a good starting point.

Problem still exists I have tried by changing the version.
Actually backendless is sending push notifications perfectly in my project but when I try to send notification in my this class (code attached above) then backendless throughs exception.

I don’t know why backendless is working perfectly in other classes but not in the “QuoteRequest.java” ???

I just ran the same code and it works just fine. Here’s the project I ran, try it on your machine:

Yes I am admitting it will be working on your machine this code also runs in my other activities also but, it conflicts with “QuoteRequest.java”

Here I have attached my source code.

QuoteRequest(backendless_support).txt (8.51kB)

Sorry, we do not review developer’s code. I copied your code into my project and it works. Try creating a separate project with the same code for the sanity check. It must be a problem with your project environment.

I have tried each and everything…
But, problem still exists…
Can you guide me in which scenarios we get this exception “java.util.HashMap cannot be cast to com.backendless.services.messaging”

In “QuoteRequest.java” I am using Map for dates. and I am using google places API for google maps. Do you think any of these two things conflict with backendless services?

Have you tried creating a clean project with just that activity to see if it works there?

Yes I have tried this also but, still app crashes

Then open my project, run it and if it works, compare the differences.

No difference between your code and my code :confused:

Then go beyond the code. Check dependencies for example.

I have checked them also…
If dependencies were not correct then my project may not send notifications in other classes.

You have two projects, a working one and non-working one. I think by following the method of elimination, you should be able to arrive at the differences between them,