Unable to retrieve device. Invalid device ID.

I called the following code but device was not registered. What can be a reason?

Backendless.Messaging.registerDevice(“my sender id”, “default”, new AsyncCallback<Void>() {
@Override
public void handleResponse(Void response) {
Log.d(TAG, "Message handleResponse: " + response);
}
@Override
public void handleFault(BackendlessFault fault) {
Log.d(TAG, "Message handleFault: " + fault.getMessage());
}
});
Backendless.Messaging.getDeviceRegistration(new AsyncCallback<DeviceRegistration>() {
@Override
public void handleResponse(DeviceRegistration response) {
Log.d(TAG, "getDeviceRegistration handleResponse: " + response);
}
@Override
public void handleFault(BackendlessFault fault) {
Log.d(TAG, "getDeviceRegistration handleFault: " + fault.getMessage());
}
});

You are using an async API and calls this methods in parallel.
There is no guaranty that device is already registered when you call gedDeviceRegistration.
You should make this call while handling the response of the registerDevice method call

The same error when I call in this way:
Backendless.Messaging.registerDevice(“senderid”, “default”, new AsyncCallback<Void>() {
@Override
public void handleResponse(Void response) {
Backendless.Messaging.getDeviceRegistration(new AsyncCallback<DeviceRegistration>() {
@Override
public void handleResponse(DeviceRegistration response) {
Log.d(TAG, "getDeviceRegistration handleResponse: " + response);

                }

                @Override
                public void handleFault(BackendlessFault fault) {
                    Log.d(TAG, "getDeviceRegistration handleFault: " + fault.getMessage());
                }
            });
        }

        @Override
        public void handleFault(BackendlessFault fault) {
            Log.d(TAG, "Message handleFault: " + fault.getMessage());
        }
    });

Do you receive an error or the device just doesn’t appear on console or in the response from the server?

Receive BackendlessFault in getDeviceRegistration handleFault and device doesn’t appear on console.

What is the message in BackendlessFault?

Unable to retrieve device. Invalid device ID

Google pushes works, but Backendless returns this error

The reason of this behaviour is that the callback is called right after the device is registered in Google (for push notifications), but the registration in our internal database is still asynchronous.

You may try to overcome this by extending onRegistered() method from BackendlessPushService and retrieving the device registrations there. Or just don’t retrieve the registrations immediately is that’s possible.

But why a device doesn’t appear in console?

In my case, it appeared in console after less than a few seconds. Do you observe anything different?

In my case BackendlessPushService onRegistered isn’t called at all.

What is your application ID?

Could I send you it to your mail?

Yes sure, send it to support@backendless.com

Done, please check.

I see the same behaviour - the device appears on console after a while. Isn’t it?

It doesn’t appear for me

I don’t see a device in console, but handleResponse method of registerDevice callback is called.

Can you please also send your sender-id value, so that I test with exact same code?