我正在使用内网IP,比如192.168.20.39和测试GCM android项目,我需要RegId:
com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401 error.我该如何解决这个问题呢?我可以用这种内网IP进行测试吗?
发布于 2014-07-17 17:19:38
这个问题还不清楚,根据你所问的,我假设了几件事。
如果是,请确保您已将此代码添加到您的注册代码块中
Registration regService = new Registration.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setRootUrl("http://192.168.20.39:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
}).build();其中,192.168.20.39必须是您的开发PC的IP (如果不是,请相应更改)。
在您的PC中,确保使用参数--address=0.0.0.0启动GCM后端服务器。添加此选项将确保服务器在本地网络中的可用性。
https://stackoverflow.com/questions/24526863
复制相似问题