Android studio Can';不要和开发者谈论谷歌云模块

Android studio Can';不要和开发者谈论谷歌云模块,android-studio,Android Studio,我有一个Android Studio项目,其中包含Android应用程序和后端Google云模块。我的开发后端的IP地址有问题。在Android文档中的示例中,它说使用10.0.2.2,我已经尝试过了,我总是得到20秒的超时。我还尝试使用我的开发机器的ip,这也会导致报告的20秒超时,即使它立即失败。在上述两种情况下,通过在浏览器中手动加载localhost:8080来验证服务器是否正在运行 // Async task snippet protected Joke doInBackground(

我有一个Android Studio项目,其中包含Android应用程序和后端Google云模块。我的开发后端的IP地址有问题。在Android文档中的示例中,它说使用
10.0.2.2
,我已经尝试过了,我总是得到20秒的超时。我还尝试使用我的开发机器的ip,这也会导致报告的20秒超时,即使它立即失败。在上述两种情况下,通过在浏览器中手动加载
localhost:8080
来验证服务器是否正在运行

// Async task snippet
protected Joke doInBackground(Void... voids) {
    if(mApiService == null) {  // Only do this once
        MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
                new AndroidJsonFactory(), null)
                // options for running against local devappserver
                // - 10.0.2.2 is localhost's IP address in Android emulator
                // - turn off compression when running against local devappserver
                .setRootUrl("http://10.0.2.2:8080/_ah/api/")
                .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
                    @Override
                    public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
                        abstractGoogleClientRequest.setDisableGZipContent(true);
                    }
                });
        mApiService = builder.build();
    }

    try {
        String text = mApiService.sayHi("Chris").execute().getData();
        return new Joke(text);
    } catch (IOException e) {
        Log.d(TAG, "fetch: " + e.getLocalizedMessage());
        return null;
    }
}
//异步任务片段
受保护的笑话背景(无效…无效){
如果(mApiService==null){//只执行一次
MyApi.Builder=new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
新的AndroidJsonFactory(),null)
//针对本地devappserver运行的选项
//-10.0.2.2是Android emulator中本地主机的IP地址
//-在本地devappserver上运行时关闭压缩
.setRootUrl(“http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(新的GoogleClientRequestInitializer(){
@凌驾
public void initialize(AbstractGoogleClientRequest AbstractGoogleClientRequest)引发IOException{
abstractGoogleClientRequest.setDisablegzip内容(true);
}
});
mApiService=builder.build();
}
试一试{
String text=mApiService.sayHi(“Chris”).execute().getData();
返回新笑话(文本);
}捕获(IOE异常){
Log.d(标记“fetch:+e.getLocalizedMessage());
返回null;
}
}

有什么想法吗?

事实证明,当我在usb连接设备上测试它时,我错过了关于在模拟器中运行的ip地址的文本片段。通过仿真器运行它效果很好:)

事实证明,我错过了关于在仿真器中运行的ip地址的文本片段,因为我正在usb连接的设备上测试它。通过模拟器运行它效果很好:)