【问题标题】:Google Appengine Android gradle taskGoogle Appengine Android gradle 任务
【发布时间】:2018-11-26 20:37:34
【问题描述】:

我在 Android Studio 的 Project build.gradle 文件中有以下任务来测试 Google Cloud Endpoint。我想在daemon 模式下运行backend:appengineRun 任务,以便让gradle 进程继续。

项目级 build.gradle:

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.google.guava:guava:22.0'
        classpath 'com.android.tools.build:gradle:3.1.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task runTestsInLocalServer {
    dependsOn = ['runLocalServer', 'runAndroidTests', 'haltLocalServer']
}

task runAppEngine (dependsOn: ":backend:appengineRun") {
        project(":backend").afterEvaluate { backend ->
            backend.extensions.appengine.daemon = true
        }
        doLast {
            println "started the server!"
        }
    }

task runAndroidTests {
    shouldRunAfter 'runAppEngine'
    dependsOn ':app:connectedCheck'
    doLast {
        println "Testing finished..."
    }
}

task haltLocalServer {
    shouldRunAfter 'runAndroidTests'
    dependsOn ':backend:appengineStop'
    doLast {
        println "Server stopped..."
    }
}

应用级 build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
    }
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    flavorDimensions "default"

    defaultConfig {
        applicationId "com.udacity.gradle.builditbigger"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    productFlavors {
        free {
            applicationId 'com.udacity.gradle.builditbigger.free'
            dimension "default"
        }
        paid {
            applicationId 'com.udacity.gradle.builditbigger.paid'
            dimension "default"
        }
    }

    lintOptions {
        abortOnError false
    }


}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    endpointsServer project(path: ':backend', configuration: 'endpoints')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.google.api-client:google-api-client:1.23.0'
    implementation 'com.google.http-client:google-http-client-android:1.23.0'
    implementation 'com.google.code.findbugs:jsr305:3.0.1'
    freeImplementation 'com.google.android.gms:play-services-ads:15.0.1'

    implementation project(':JokeProvider')
    implementation project(':jokedisplay')

    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testImplementation 'junit:junit:4.12'
}

这是我得到的错误:

Caused by: groovy.lang.MissingPropertyException: Could not set unknown property 'daemon' for object of type com.google.cloud.tools.gradle.appengine.core.AppEngineExtension.
    at org.gradle.internal.metaobject.AbstractDynamicObject.setMissingProperty(AbstractDynamicObject.java:118)
    at org.gradle.internal.metaobject.AbstractDynamicObject.setProperty(AbstractDynamicObject.java:75)
    at com.google.cloud.tools.gradle.appengine.core.AppEngineExtension_Decorated.setProperty(Unknown Source)
    at org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:197)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:484)

【问题讨论】:

  • 您似乎缺少一些依赖或导入。可以放完整代码吗?
  • 更新了代码。

标签: android google-app-engine gradle groovy


【解决方案1】:

我建议你关注这个doc

我认为您必须在代码中添加一些行(项目级 build.gradle):

     repositories {
        ...
        mavenCentral()   <---
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-17
    • 1970-01-01
    • 2014-10-19
    • 1970-01-01
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多