I am getting following error while building Android project in Android Studio 1.2.2 (fresh instalation)
Error:(76, 0) Could not find property 'unitTestVariants' on com.android.build.gradle.internal.dsl.TestOptions_Decorated@261be0aa.
Gradle version is 2.4
Android build gradle version is 1.2.3
Android-apt version is 1.4
Android SDK version is 19.
If gradle --version works, but all of your builds fail with the same error, it is possible there is a problem with one of your Gradle build configuration scripts. You can verify the problem is with Gradle scripts by running gradle help which executes configuration scripts, but no Gradle tasks.
It's helpful to remember that you will have build.gradle files for each module in your Android Studio Project. I kept hitting my head against the wall - "Where the heck is that line everyone's telling me to change?!"
So for now either use android apt plugin version 1.4, or Android gradle plugin version 1.3 (see instructions below). Note that gradle version itself doesn't matter as far as this bug is concerned and you could use 2.4 as well as 2.2.1.
Check the Internet Connection - it should not fluctuate while building the project Build>> Clean Project Or Rebuild Project. I fixed the error by inserting following lines in gradle.properties: This sets the Gradle's connection timeout from the default 30s to 180s (3m).
You should navigate to your libs folder in the IDE, right click on the jar and select to add the library to the project, it still needs to establish the dependency even though the jar appears to be there. Also look at your gradle built script to make sure the dependency appears there.
This is triggered by the Android apt plugin using the unitTestVariants
property in its 1.5
version which is only available in the Android gradle plugin from version 1.3
onwards (cf. bug report).
So for now either use android apt plugin version 1.4
, or Android gradle plugin version 1.3
(see instructions below).
Note that gradle version itself doesn't matter as far as this bug is concerned and you could use 2.4
as well as 2.2.1
.
1.3
buildscript
block references jcenter()
(the beta versions aren't on maven)'com.android.tools.build:gradle:1.2.3'
by 'com.android.tools.build:gradle:1.3.0-beta4'
1.4
(courtesy of @emarc-magtanong)
com.neenbedankt.gradle.plugins:android-apt:1.4
and not com.neenbedankt.gradle.plugins:android-apt:1.5
nor com.neenbedankt.gradle.plugins:android-apt:+
.Use gradle 2.4. This happened to me as well and tried for it to work with gradle 2.2.1 changing the build tools and android gradle plugin. The only thing that worked was to update gradle. You can update the gradle wrapper.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With