Google App Engine - 云端点 - 未设置应用程序名称

JR *_*lia 9 google-app-engine android

我刚开始使用Google Cloud Endpoints.

运行Android应用程序时,我在logcat中有以下警告:

Tag: AbstractGoogleClient
Text: Application name is not set. Call Builder#setApplicationName.
Run Code Online (Sandbox Code Playgroud)

在哪里设置应用程序名称?它是在Android或应用程序引擎/云端点?

Tom*_*per 6

班级com.google.api.client.googleapis.services.AbstractGoogleClient有一个功能

public Builder setApplicationName(String applicationName) {
      this.applicationName = applicationName;
      return this;
    }
Run Code Online (Sandbox Code Playgroud)

当使用摇篮生成您的客户端库使用appengineEndpointsInstallClientLibs 您应该能够为您的端点创建endpointbuilder:

private YourEndpoint.Builder endpointBuilder = new YourEndpoint.Builder(
            AndroidHttp.newCompatibleTransport(), new JacksonFactory(),
            new HttpRequestInitializer() {
                public void initialize(HttpRequest httpRequest) {
                }
            }
    );
Run Code Online (Sandbox Code Playgroud)

然后......摆脱警告:

endpointBuilder.setApplicationName("Some crazy App Name");
Run Code Online (Sandbox Code Playgroud)