android-gradle-plugin 1.2.2: 标记 ignoreFailures 导致任务 connectedAndroidTest 出错
android-gradle-plugin 1.2.2: Flag ignoreFailures causes error in task connectedAndroidTest
我更新了我的 build.gradle 以使用 android-gradle 插件 1.2.2(而不是 1.1.0):
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
}
之后,如果我尝试同步我的项目,我会遇到异常。
我的 build.gradle
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'LICENSE.txt'
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.kupferwerk.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 100
versionName "1.0.0"
}
lintOptions {
abortOnError false
disable 'ContentDescription'
disable 'InvalidPackage'
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
testCoverageEnabled true
}
}
}
project.gradle.taskGraph.whenReady {
connectedAndroidTest {
ignoreFailures = true
}
}
错误是
Error:(58) No such property: ignoreFailures for class: org.gradle.api.DefaultTask_Decorated
在我的 build.gradle-文件的这一部分中:
project.gradle.taskGraph.whenReady {
connectedAndroidTest {
ignoreFailures = true
}
}
有人知道标志 ignoreFailures
是否被删除或重命名了吗?我该如何解决这个问题?
编辑:这是堆栈跟踪:
groovy.lang.MissingPropertyException: No such property: ignoreFailures for class: org.gradle.api.DefaultTask_Decorated
at org.gradle.api.internal.plugins.ExtraPropertiesDynamicObjectAdapter.setProperty(ExtraPropertiesDynamicObjectAdapter.java:46)
at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:119)
at org.gradle.api.DefaultTask_Decorated.setProperty(Unknown Source)
at build_bbosu6ukmbcd6hf72mh10z6fq$_run_closure3_closure14.doCall(/Users/chsc/Development/MyApplication/app/build.gradle:58)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:63)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)
at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:482)
at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:58)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:55)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$ContainerElementsDynamicObject.invokeMethod(DefaultNamedDomainObjectCollection.java:324)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_bbosu6ukmbcd6hf72mh10z6fq$_run_closure3.doCall(/Users/chsc/Development/MyApplication/app/build.gradle:57)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy9.graphPopulated(Unknown Source)
尝试使用:
project.gradle.taskGraph.whenReady {
connectedAndroidTestDebug {
ignoreFailures = true
}
}
更具体地说:connectedAndroidTest[YourFlavor][Debug]
随着 gradle-plugin 1.3.0 的发布,任务名称再次更改:
project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
And, nice hint from StefanTo:
但是如果你有任何Flavor,上面会报错,你需要在task-name中包含Flavor-name,比如:
connectedMyFlavorNameDebugAndroidTest
在较新的 Gradle-plugin 版本中,执行如下操作:
project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
或者,如果您有多种口味,请执行以下操作:
// ...
project.gradle.taskGraph.whenReady {
android.productFlavors.all { flavor ->
// Capitalize (as Gralde is case-sensitive).
def flavorName = flavor.name.substring(0, 1).toUpperCase() + flavor.name.substring(1)
// At last, configure.
"connected${flavorName}DebugAndroidTest" {
ignoreFailures = true
}
}
}
我更新了我的 build.gradle 以使用 android-gradle 插件 1.2.2(而不是 1.1.0):
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
}
之后,如果我尝试同步我的项目,我会遇到异常。 我的 build.gradle
apply plugin: 'com.android.application'
android {
packagingOptions {
exclude 'LICENSE.txt'
}
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.kupferwerk.myapplication"
minSdkVersion 15
targetSdkVersion 22
versionCode 100
versionName "1.0.0"
}
lintOptions {
abortOnError false
disable 'ContentDescription'
disable 'InvalidPackage'
}
buildTypes {
release {
minifyEnabled false
proguardFiles 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
testCoverageEnabled true
}
}
}
project.gradle.taskGraph.whenReady {
connectedAndroidTest {
ignoreFailures = true
}
}
错误是
Error:(58) No such property: ignoreFailures for class: org.gradle.api.DefaultTask_Decorated
在我的 build.gradle-文件的这一部分中:
project.gradle.taskGraph.whenReady {
connectedAndroidTest {
ignoreFailures = true
}
}
有人知道标志 ignoreFailures
是否被删除或重命名了吗?我该如何解决这个问题?
编辑:这是堆栈跟踪:
groovy.lang.MissingPropertyException: No such property: ignoreFailures for class: org.gradle.api.DefaultTask_Decorated
at org.gradle.api.internal.plugins.ExtraPropertiesDynamicObjectAdapter.setProperty(ExtraPropertiesDynamicObjectAdapter.java:46)
at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:119)
at org.gradle.api.DefaultTask_Decorated.setProperty(Unknown Source)
at build_bbosu6ukmbcd6hf72mh10z6fq$_run_closure3_closure14.doCall(/Users/chsc/Development/MyApplication/app/build.gradle:58)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:63)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)
at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:482)
at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:58)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:55)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)
at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$ContainerElementsDynamicObject.invokeMethod(DefaultNamedDomainObjectCollection.java:324)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_bbosu6ukmbcd6hf72mh10z6fq$_run_closure3.doCall(/Users/chsc/Development/MyApplication/app/build.gradle:57)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:40)
at org.gradle.listener.ClosureBackedMethodInvocationDispatch.dispatch(ClosureBackedMethodInvocationDispatch.java:25)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:83)
at org.gradle.listener.BroadcastDispatch.dispatch(BroadcastDispatch.java:31)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy9.graphPopulated(Unknown Source)
尝试使用:
project.gradle.taskGraph.whenReady {
connectedAndroidTestDebug {
ignoreFailures = true
}
}
更具体地说:connectedAndroidTest[YourFlavor][Debug]
随着 gradle-plugin 1.3.0 的发布,任务名称再次更改:
project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
And, nice hint from StefanTo:
但是如果你有任何Flavor,上面会报错,你需要在task-name中包含Flavor-name,比如:
connectedMyFlavorNameDebugAndroidTest
在较新的 Gradle-plugin 版本中,执行如下操作:
project.gradle.taskGraph.whenReady {
connectedDebugAndroidTest {
ignoreFailures = true
}
}
或者,如果您有多种口味,请执行以下操作:
// ...
project.gradle.taskGraph.whenReady {
android.productFlavors.all { flavor ->
// Capitalize (as Gralde is case-sensitive).
def flavorName = flavor.name.substring(0, 1).toUpperCase() + flavor.name.substring(1)
// At last, configure.
"connected${flavorName}DebugAndroidTest" {
ignoreFailures = true
}
}
}