gpt4 book ai didi

java - 物理设备测试和 google-app-engine 后端

转载 作者:行者123 更新时间:2023-11-30 11:14:31 24 4
gpt4 key购买 nike

我正在关注 this tutorial尝试制作一个带有谷歌应用引擎后端的 andorid 应用程序。我正处于要测试我的应用程序和 GAE Api 之间的连接的地步本地 所以我尝试在我的 Nexus 5 手机上执行以下代码(未模拟).

MainActivity.java

public class MainActivity extends FragmentActivity {

private final String DEBUG_TAG = "MainActivity";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

/**
* AsyncTask for calling Mobile Assistant API for checking into a place (e.g., a store)
*/
private class CheckInTask extends AsyncTask<Void, Void, Void> {
/**
* Calls appropriate CloudEndpoint to indicate that user checked into a place.
*
* @param params the place where the user is checking in.
*/
@Override
protected Void doInBackground(Void... params) {
CheckIn checkin = new CheckIn();
// Set the ID of the store where the user is.
// This would be replaced by the actual ID in the final version of the code.
checkin.setPlaceId("StoreNo123");
Checkinendpoint.Builder builder = new Checkinendpoint.Builder(
AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
null);
builder = CloudEndpointUtils.updateBuilder(builder);
Checkinendpoint endpoint = builder.build();
try {
endpoint.insertCheckIn(checkin).execute();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
}

我明白了

And I get this

我应该从哪里得到这个

Where I shouldget this
(来源:google.com)

日志显示:java.net.SocketTimeoutException:20000 毫秒后无法连接到/10.0.2.2(端口 8888)

“实体种类”列表中没有 CheckIn 可用

  • 我在本地启动了应用程序引擎,我得到:INFOS: Dev App Server is now running
  • 我已将 CloudEndPointUtils.java 设置为:LOCAL_ANDROID_RUN = true; LOCAL_APP_ENGINE_SERVER_URL = "http://localhost:8888/";LOCAL_APP_ENGINE_SERVER_URL_FOR_ANDROID = "http://10.0.2.2:8888";

我感觉是因为我用的是物理设备调试...

您怎么看以及如何让它发挥作用?

(我不知道如何在我的计算机上运行 android 模拟器,所以如果有其他解决方案会很棒)

编辑:我已尝试部署应用,但我遇到了同样的问题和相同的日志错误。

最佳答案

这是因为10.0.2.2是使用模拟器时的localhost地址。如果你想在你的设备上尝试,并且你的所有计算机和设备都连接到本地网络,请尝试将服务器地址更改为 http://local-network-ip:port/_ah/api.启动 appengine 应用程序时,将主机地址设置为 0.0.0.0 以使其可供网络上的其他机器访问。

关于java - 物理设备测试和 google-app-engine 后端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25876926/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com