【问题标题】:Android Studio Integrating Google Endpoints Generated librariesAndroid Studio 集成 Google Endpoints 生成的库
【发布时间】:2013-08-15 11:21:34
【问题描述】:

我正在尝试包含一个生成的客户端库以向我的 Android Studio 进程查询 Google Cloud Endpoints。

我已将依赖库包含在项目的/libs 文件夹中。

我已经解压缩了包含我正在使用的 API 的特定代码的 .jar 源。我已将其复制粘贴到我的源文件夹中。

当我尝试编译我的项目时,在生成的 API 文件中遇到编译错误。

这是我的 builg.gradle 文件。

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
   compileSdkVersion 17
   buildToolsVersion "17.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }
}


dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile 'com.google.android.gms:play-services:3.1.36'
    compile fileTree(dir: "libs/google_end_points/", includes: ['*.jar'])
}

我收到了几个类似这样的编译错误(注意 com.google.api.services.positivityapi 是从 Google Cloud Endpoints 生成的 API):

Gradle: com.google.api.services.positivityapi.Positivityapi.Appreciation.List is already defined in com.google.api.services.positivityapi.Positivityapi.Appreciation

我有几个问题:

  • 如何解决我的问题?
  • 我是否在我的 Android 项目中正确地包含了这些库?

感谢您的帮助

【问题讨论】:

  • 我尝试在 Eclipse 中包含这些库,但仍然出现此编译错误。如果我使用 Javascript API,Endoinpts 正在工作。我想知道问题本身与生成的源代码无关。我不负责 GAE 和端点开发,我只知道它是用 python 开发的。我将尝试获取有关使用的版本的更多信息。

标签: android android-studio google-cloud-endpoints


【解决方案1】:

以该文件为例调整您的 build.grade 文件。这将动态拉入依赖项并防止您必须签入它们。

https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-android/blob/master/HelloEndpointsProject/HelloEndpoints/build.gradle

如果您仍然缺少依赖项,请确保您已按照同一项目的 README 文件中的说明从 SDK 管理器下载了所需的包:

https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-android

【讨论】:

  • 问题出在 python 代码中,该代码在他的代码中遵守了一些命名约定。所以java生成的代码是不正确的。没有编译是正常的。我将尝试与我们团队中的 python 开发人员获取更多详细信息,以便为可能遇到相同问题的人提供更多详细信息。
  • 我在使用名为Entry 的模型时遇到了问题,我遇到了编译器错误:找不到名为MyApiNameEntry 的生成类的符号然后我更改了类的名称,它运行良好。
猜你喜欢
  • 2014-10-06
  • 1970-01-01
  • 1970-01-01
  • 2014-06-11
  • 1970-01-01
  • 1970-01-01
  • 2013-08-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多