Gradle 未找到 DSL 方法:'appengine()'

Gradle DSL method not found: 'appengine()'

我的项目由一个 Android 应用程序和一个 Appengine 后端组成,我从 eclipse 转移到 android studio 并遵循一些在线示例并从 Android 生成一个 appengine 模块工作室我想出了这个。

android 应用程序的 Gradle 文件

apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    //compile project(':appcompat_v7_2')
    compile 'com.android.support:support-v4:21.0.3'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile project(path: ':AgriExpenseTT-AppEngine', configuration: 'android-endpoints') //line that supposedly links the AppengineProject
}

android {
compileSdkVersion 19
buildToolsVersion "20.0.0"

defaultConfig {
    minSdkVersion 9
    targetSdkVersion 20
}

sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
        resources.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
        aidl.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
        renderscript.srcDirs = ['src', 'endpoint-libs/libdeviceinfoendpoint-v1/deviceinfoendpoint/deviceinfoendpoint-v1-generated-source', 'endpoint-libs/librpurchaseendpoint-v1/rpurchaseendpoint/rpurchaseendpoint-v1-generated-source', 'endpoint-libs/libupaccendpoint-v1/upaccendpoint/upaccendpoint-v1-generated-source', 'endpoint-libs/libcycleendpoint-v1/cycleendpoint/cycleendpoint-v1-generated-source', 'endpoint-libs/libtranslogendpoint-v1/translogendpoint/translogendpoint-v1-generated-source', 'endpoint-libs/libmessageEndpoint-v1/messageEndpoint/messageendpoint-v1-generated-source', 'endpoint-libs/libcycleuseendpoint-v1/cycleuseendpoint/cycleuseendpoint-v1-generated-source']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }

    // Move the tests to tests/java, tests/res, etc...
    instrumentTest.setRoot('tests')

    // Move the build types to build-types/<type>
    // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
    // This moves them out of them default location under src/<type>/... which would
    // conflict with src/ being used by the main source set.
    // Adding new build types or product flavors should be accompanied
    // by a similar customization.
    debug.setRoot('build-types/debug')
    release.setRoot('build-types/release')
}
}

appengine 的 gradle 文件

apply plugin: 'java'
dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')

    compile 'com.google.appengine:appengine-endpoints:1.9.1'
    compile 'com.google.appengine:appengine-endpoints-deps:1.9.1'
    compile 'javax.servlet:servlet-api:2.5'
    compile 'org.datanucleus:datanucleus-core:3.2.8'
    compile 'com.google.appengine.orm:datanucleus-appengine:2.1.2'
    compile group: 'javax.persistence', name: 'persistence-api', version: '1.0'
}
repositories {
    mavenCentral()
}
sourceSets {
    main.java.srcDirs = ['src']
    main.resources.srcDirs = ['src']
    test.java.srcDirs = ['tests/java']
    test.resources.srcDirs = ['tests/resources']
}

appengine { // ! ERROR IS HERE !
downloadSdk = true
appcfg {
    oauth2 = true
}
endpoints {
    getClientLibsOnBuild = true
    getDiscoveryDocsOnBuild = true
}
}

错误

Could not find method appengine() for arguments        [build_8nkni14q2n6l61jnsyaantjd6$_run_closure4@188b4628] on project ':AgriExpenseTT-AppEngine'

在这里,您可以找到如何将 App Engine 与 gradle 一起使用的指南:https://github.com/GoogleCloudPlatform/gradle-appengine-plugin

要使用 App Engine 插件,请在您的构建脚本中包含:

apply plugin: 'appengine'

需要在构建脚本的类路径中定义插件 JAR。它直接在 Maven Central 上可用。或者,您可以从 GitHub 下载它并将其部署到您的本地存储库。以下代码片段显示了如何从 Maven Central 检索它的示例:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.google.appengine:gradle-appengine-plugin:1.9.17'
    }
}

注意:该插件需要您设置环境变量 APPENGINE_HOME 或系统 属性 appengine.sdk.root 指向您当前的 Google App Engine SDK 安装。如果您同时设置了两个变量,则系统 属性 优先于环境变量。或者,您可以通过将约定 属性 downloadSdk 设置为 true 来选择自动下载 SDK。该选项需要您通过设置配置appengineSdk来指定您要使用的SDK版本。

dependencies {
    appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.17'
}