我在Android Studio的Project build.gradle
文件中有以下任务来测试Google Cloud Endpoint。我想在backend:appengineRun
模式下运行daemon
任务,因此它允许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..."
}
}
App level 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)
答案 0 :(得分:0)
我建议您遵循此doc。
我认为您必须在代码中添加几行(项目级build.gradle):
repositories {
...
mavenCentral() <---
}
和
dependencies {
...
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.59' <---
}