android-gradle-plugin 1.2.2:标志ignoreFailures导致任务connectedAndroidTest出错

时间:2015-05-07 12:13:48

标签: android gradle android-gradle

我将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)

2 个答案:

答案 0 :(得分:9)

随着gradle-plugin 1.3.0的发布,任务的名称再次被更改:

project.gradle.taskGraph.whenReady {
   connectedDebugAndroidTest {
      ignoreFailures = true
   }
}
编辑:StefanTo的好提示:

更具体地说:connected[YourFlavor][Debug]AndroidTest

答案 1 :(得分:2)

尝试使用:

project.gradle.taskGraph.whenReady {
   connectedAndroidTestDebug {
      ignoreFailures = true
   }
}

更具体一点:connectedAndroidTest [YourFlavor] [Debug]