我一直在努力让示例从下面运行:
https://developers.google.com/eclipse/docs/getting_started
我遇到的第一个问题是没有在 Android SDK 中安装“Google Cloud Messaging for Android Library”(我知道这很明显)。
但现在我对 Android 项目中两个文件中的自动生成代码有疑问: GCMIntentService.java 和 RegisterActivity.java
错误是:
- 方法 getDeviceInfo(String) 未定义类型 Deviceinfoendpoint GCMIntentService.java
- 方法 listMessages() 未定义 MessageEndpoint RegisterActivity.java 类型
- 未为类型 Deviceinfoendpoint GCMIntentService.java 定义方法 insertDeviceInfo(DeviceInfo)
- 未为类型 Deviceinfoendpoint GCMIntentService.java 定义 removeDeviceInfo(String) 方法
我在 Ubuntu 上使用 Java SDK v1.7.0_15,但我也尝试在 Windows 7 上使用 Java SDK v1.6,但遇到了同样的问题。最新的 Android 平台 4.2.2 和 Google App Engine 1.7.7。 Eclipse 是 Juno Service Release 2。
问题看起来他们做错了一些转换,因为在 Deviceinfoendpoint 内部类 DeviceInfoEndpoint 有一个方法 getDeviceInfo(不同的 capatilisations)。
我可以尝试修复它,但只是想知道我的设置是否有问题导致发生这种情况?
如有任何帮助,我们将不胜感激。
最佳答案
在您的 GCMIntentService.java 类中,在出现错误的行中的端点对象之后添加 .deviceInfoEndpoint(),如下所示:
DeviceInfo existingInfo = endpoint.getDeviceInfo(registration)
DeviceInfo existingInfo = endpoint.deviceInfoEndpoint().getDeviceInfo(registration)
在 RegisterActivity.java 中更改行
messageEndpoint.listMessages().setLimit(5).execute();
到
messageEndpoint.messageEndpoint().listMessages().setLimit(5).execute();
关于java - Google App Engine Java 和 Android 入门,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16047737/