Я пишу бэкенд для Google App EngineНайдено: 'java.util.Date', требуется: '' com.google.api.client.util.DateTime GAE
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
import java.util.Date;
@Entity
public class DeviceData {
/**
* Unique identifier of this Entity in the database.
*/
@Id
private Long key;
@Index
private UserDevice device;
public Date date;
//getters and setters
}
И конечная точка, как
@ApiMethod(httpMethod = "POST")
public final DeviceData updateDeviceData(UserDevice device,@Named("date") Date date, User user) throws ServiceException {
DeviceData newDeviceLocation = new DeviceData();
newDeviceLocation.setDevice(device);
newDeviceLocation.setLatitude(latitude);
newDeviceLocation.setLongitude(longitude);
newDeviceLocation.setDate(date);
OfyService.ofy().save().entity(newDeviceLocation).now();
return newDeviceLocation;
}
Но когда я пытаюсь вызвать его из моего Android App как
deviceLocatorApi.devicedata().updateDeviceData(new Date(), userDevice).execute();
это дает следующее сообщение об ошибке
Found: 'java.util.Date', required: 'com.google.api.client.util.DateTime' more.. Error:(49, 45) error: method updateDeviceData in class DeviceLocator.Devicedata cannot be applied to given types; required: DateTime,UserDevice found: Date,UserDevice reason: actual argument Date cannot be converted to DateTime by method invocation conversion
Я выполнил поиск уровня рабочей области и не нашел DateTime
класс в любом месте. Так откуда это происходит. Также как здесь изменился порядок аргументов. Первый аргумент должен был иметь тип UserDevice и 2nd типа Date?
От каких 'jar' вы получаете доступ к' DeviceData.java'? – Henry
Не понял. Я использую студию и добавил модуль GAE в приложение для Android. Зависимости автоматически обрабатываются. –
Не могли бы вы проверить, перегружен ли метод 'updateDeviceData'? Если это так, вы можете использовать неправильную подпись. – Henry