Gradle build error in Android Studio - android

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.

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.
Use Android gradle plugin >= 1.3
make sure the projects buildscript block references jcenter() (the beta versions aren't on maven)
replace all instances of 'com.android.tools.build:gradle:1.2.3' by 'com.android.tools.build:gradle:1.3.0-beta4'
re-sync the gradle project from within AndroidStudio
Use Android apt plugin <= 1.4
(courtesy of #emarc-magtanong)
make sure all references to the Android apt plugin read 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.

Related

Gradle Play Publisher's minimum Gradle version is at least Gradle 7.0.2 and yours is Gradle 6.5

I tried to configure my gradle file to use gradle plugin followig this tutorial: https://github.com/Triple-T/gradle-play-publisher#authenticating-gradle-play-publisher but now i'm getting this error in the title
These is my gradle version:
screenshot
It's warning me to change my gradle version to 7.0.2 and android gradle version to 7
So i change my version to this: screenshot
The problem is after i did that and sync the project i received this error: This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2020.3.1 or newer.
My android studio is 4.1.3 by the way which i think it's the latest one

This version of the Android Support plugin for IntelliJ IDEA

This version of the Android Support plugin for IntelliJ IDEA (or
Android Studio) cannot open this project, please retry with version
4.3 or newer.
The Gradle version is
classpath 'com.android.tools.build:gradle:7.0.0-alpha05'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip
I'm using Android Studio Arctic Fox 2020.3.1 canary 10. I downgraded the Gradle to 7.0.0-alpha10 and it worked well.
Check your Android Studio Version (Help->About) e.g. 4.1.2
Update build.gradle class path to your version:
classpath 'com.android.tools.build:gradle:4.1.2'
where 4.1.2 is the version found under Help->About
Alternatively, you could just update your Android Studio Version to what is suggested.
JetBrains's support gave the similar answer as wandesky:
The message means that the Android plugin bundled with 2021.2 version
is not compatible with the Android Gradle plugin used by your Gradle
project:
com.android.tools.build:gradle:7.0.0
You will need to either use lower Gradle plugin version or use Android
Studio IDE to develop this project until IntelliJ IDEA merges latest
updates of Android plugin from the Android Studio IDE.
The classpath 'com.android.tools.build:gradle:4.2.1' should work fine
in 2021.2 IntelliJ IDEA.
(source)

Android Realm 4.3.1 Cannot change Gradle plugin version

I use Realm 4.3.1. I found a question that is my Gradle plugin version auto updated. But my Gradle plugin version setting is 3.0.1 and when I build the project AndroidStudio tells me it is using Gradle plugin 3.1.0-Alpha3, ignoring my build tool version 25.0.3, as shown below.
So I removed Realm 4.3.1, and my Gradle plugin 3.0.1 works - this is my project build.gradle
That's a bug in 4.3.0 because of some trickiness with the maven publish plugin on the Realm side.
It was fixed in 4.3.2.
4.3.2 (2018-01-17)
Bug Fixes
Prevent Realms Gradle plugin from transitively forcing specific versions of Google Build Tools onto downstream projects (#5640).

Open project in Android Studio 1.0+ using gradle plugin 0.*.*

I am trying to open a Android Project in Android Studio 1.0.2 which uses
classpath 'com.android.tools.build:gradle:0.12.+'
as its dependency. On opening the project with above dependency I get the following error message.
The project is using an unsupported version of the Android Gradle plug-in (0.12.2). The recommended version is 1.0.0.
Is there a way to run such projects in Android Studio 1.0.+ without upgrading the Gradle plug-in version
Note:
I can upgrade the gradle version and plugin to get it to work OR simply use older version of Android Studio to open the project.
First approach is not desirable since this being a community project I will prefer to leave majority of files unchanged and changing gradle version will also hinder me from testing the build with 0.12.
To successfully build Android project using Android Studion and Gradle you need to use the AS, Gradle and Android Gradle Plugin with versions which are compatible with each other. Check out this page, it's said here, that you can use Android Gradle Plugin 0.12 with Android Studio 0.8.0 - 0.8.11 and there is no way to use it under Android Studio 1.0.
I suggest you convince other people to switch to the newest version of Android Gradle Plugin because 1.0.0 is the stable one and doesn't contain some bugs which were out there in the 0.12.+.

relation between gradle version and gradle build tool version

I'm new to gradle and got 2 questions:
gradle itself is a build tool, so why is the need for Android gradle tool com.android.tools.build:gradle:0.7.+ in the script?
What is the relation between the version of gradle installed (say 1.9) and the version of that Android gradle tool, like 0.7.+ in classpath 'com.android.tools.build:gradle:0.7.+'. If I changed the latter's version to 0.8.+ then the build fails on 'could not find plugin AppPlugin'.
1) Gradle is a build tool, but it requires specific plugin to work.
Android Tool Team is releasing the Android plugin for Gradle.
com.android.tools.build:gradle:0.6.+
com.android.tools.build:gradle:0.7.+
com.android.tools.build:gradle:0.8.+
Here you can find the repo:
https://android.googlesource.com/platform/tools/base/
The current dev branch is idea133. Otherwise you can check gradle_0.8/gradle_0.7 branches.
2) There is a relation between gradle-plugin and the gradle version.
For example
com.android.tools.build:gradle:0.6.+ -> gradle 1.8
com.android.tools.build:gradle:0.7.+ -> gradle 1.9
com.android.tools.build:gradle:0.8.+ -> gradle 1.9/1.10
You can find gradle version used in your project in the file gradle/wrapper/gradle-wrapper.properties
Also there is a relation between gradle-plugin and the IDE version.
For example:
Android Studio 0.3.x -> gradle-plugin 0.6
Android Studio 0.4.x -> gradle-plugin 0.7
Android Studio 0.4.3+ -> gradle-plugin 0.8
For updated news you can check this link: http://tools.android.com/recent
You can also check this updated post:
Android Studio Gradle issue upgrading to version 0.5.0 - Gradle Migrating From 0.8 to 0.9 - Also Android Studio upgrade to 0.8.1
If you change your plugin version, check compatibility, and then click sync project with your gradle files.It will download a new plugin version if you need it.
I will try to answer your questions.
As you said, Gradle is a build tool, but the line you have mentioned in your first question is referring to Gradle Java plugin version. Gradle has plugin for building Java projects. These plugins extend upon the general purpose build tool Gradle is, and may provide additional features. You can read more about the Gradle plugins here.
The reason your build fails when you change the plugin version is simple, the plugin version 0.8 is not there. There is a relationship between Gradle version and the plugin version and a developer has to maintain that. You can only use a plugin version which has been released and is compatible with the Gradle version. I hope the answer to first question answers this anyways.

Categories

Resources