Android Studio集成Google端点生成的库

时间:2013-08-15 11:21:35

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

我正在尝试添加生成的客户端库,以便将Google Cloud Endpoints查询到我的Android Studio流程。

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

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

Project Tree

当我尝试编译项目时,我在生成的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项目中正确包含了库?

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

使用此文件调整build.grade文件作为示例。这将动态地引入依赖关系,并防止您必须检查它们。

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

如果您仍然缺少依赖项,请确保已从SDK管理器中下载了所需的软件包,如同在同一项目的自述文件中指定的那样:

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

相关问题