生成Maven GAE端点库并将其导入Android Studio

时间:2015-02-18 04:14:21

标签: android google-app-engine maven android-studio google-cloud-endpoints

我在Java中有一个Maven Google App Engine端点API。我按照这些instructions编译了JAR。

我最近从Eclipse过渡到Android工作室。我正在尝试将JAR导入Android Studio。我将此行添加到build.gradle:

compile files('./libs/warAPI-v1-1.19.1-SNAPSHOT.jar')

我还需要向build.gradle添加哪些其他依赖项?我似乎无法在任何地方找到列表。

2 个答案:

答案 0 :(得分:2)

点击按钮Sync Project With Gradle Files可以解决您的问题:

  

工具 - > Android - >使用Gradle文件同步项目

如果失败,请尝试运行Rebuild project

  

构建 - >重建项目

答案 1 :(得分:0)

这些是我最后添加的依赖项:

的build.gradle

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.18.0-rc') {
        // Exclude artifacts that the Android SDK/Runtime provides.
        exclude(group: 'xpp3', module: 'xpp3')
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
        exclude(group: 'junit', module: 'junit')
        exclude(group: 'com.google.android', module: 'android')
    }
    compile(group: 'com.google.api-client', name: 'google-api-client-android',
            version: '1.18.0-rc') {
        exclude(group: 'com.google.android.google-play-services', module: 'google-play-services')
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }
    compile(group: 'com.google.api-client', name: 'google-api-client-gson', version: '1.18.0-rc') {
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }
    compile(group: 'com.google.http-client', name: 'google-http-client-android',
            version: '1.18.0-rc') {
        exclude(group: 'com.google.android', module: 'android')
        exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    }
    compile files('./libs/warAPI-v1-1.19.1-SNAPSHOT.jar')

    compile(group: 'com.google.guava', name: 'guava', version: '18.0-rc2')
}