Force Android Studio to use gradle 4.1 - android-studio

I have downloaded a previous version of Android Studio (3.0.1) since I must use the android gradle plugin version 3.0.1 and gradle 4.1.
The code, and the other modules it depends on, were written using Android Studio 3.2, kotlin 1.3.10 and gradle version 4.10.2
When I try to synchronize the project with the older version of Android Studio (3.0.1) or running gradlew assembleDebug it says the minimum gradle version is 4.6 even though the gradle wrapper version is 4.1 and the gradle plugin version is 3.0.1. The kotlin version for all dependencies was set on 1.2.41
This is the error:
Minimum supported Gradle version is 4.6. Current version is 4.1.
Please fix the project's Gradle settings. Fix Gradle wrapper and
re-import project Gradle settings
How can I compile such project using older the older version?

You have to use newer gradle wrapper and plugin in order to compile your project, if you want to use AS 3.2. So there is two options for you - upgrade wrapper and plugin, or downgrade AS, plugin, wrapper and kotlin in all dependencies.

Related

Unrecognized Android Studio version

Unrecognized Android Studio (or Android Support plugin for IntelliJ IDEA) version '202.7660.26.42.7486908', please retry with version 2020.3.1 or newer.
To solve this issue you can either open your project with android studio version 2020.3.1 or just change Android Gradle Plugin Version in the project stucture settings to the version that your Android Studio supports, I use Android Studio 4.2.2 so I changed the version to 4.2.2 and it works for me.
1. Why
It happens if the Intellij Android Support plugin version used has a lower major/minor version than the current Android Gradle plugin
2. How
You have three options.
Add android.injected.studio.version.check=false to gradle.properties to temporary stop AGP version checking
Upgrade Android Studio to the newest version (Maybe the Canary builds)
Preview builds can be installed side by side with stable versions.(Sugguest)
Downgrade Android Gradle Plugin Version to fit your Android Studio
Read More
1- change your go-to the build.gradle -> in allprojects -> repositories then change the jcenter() to mavenCentral()
2- open file ->project structure -> project -> change the Android Gradle Plugin Version to 4.2.2 and gradle version to 7.0.2
This is one of the main problems of this error.
This happens because of the Intellij android support plugin has a lower major/minor version than the Current gradle plugin.
To fix this error please go through these steps
open file ->project structure -> project -> change the Android Gradle Plugin Version to 4.2.2 and gradle version to 7.0.2
This step fixes my error.
Thank You
T

After i added some dependencies in my updated android studio version 4.0.1,

I faces with 3 errors.
*upgrade plugin to version 4.0.1 & sync project
*project may be using a version of gradle that does not contain the method
*Apply gradle plugin
My android gradle plugin version is already 4.0.1 still error is showing upgrade plugin
to version 4.0.1 .
Goto File -> Project Structure
Within the project set Your Gradle version to the latest version.
This might help.

org.gradle.tooling.model.UnsupportedMethodException: Unsupported method: AndroidArtifact.getBuildConfigFields()

I was building my android project on Android Studio 4.2.1.
but I get this error:
org.gradle.tooling.model.UnsupportedMethodException: Unsupported method:
AndroidArtifact.getBuildConfigFields().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
my Gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
my Gradle plugin tools version:
com.android.tools.build:gradle:4.1.0-alpha09
The both Gradle and Gradle plugin are the latest versions. The exception says that I need to update/change the connected Gradle version.
I am impossible to upgrade further version because I am already on the latest version. So, the only thing I can do is changing the grade version, but which one?
I was able to build project successfully by using :
classpath 'com.android.tools.build:gradle:4.0.0'
But if you are trying to use jetpack compose you will have to use latest canary version of android studio.

Where is gradle build tools version set?

I have installed sdk build tools version 28.0.2, and set buildToolsVersion = "28.0.2" in build.gradle. Yet when I run ./gradlew installDebug, I get an error message saying The SDK Build Tools revision (23.0.1) is too low for project.
I even UNinstalled version 23.01.1 via the android studio sdk manager - but then when I run gradlew it reinstalled it!
I ran grep -ri buildtool * to try and find where it might be, but the only reference I could find was in build.grade.
I managed to work around this by upgrading my gradle version to 3.1.0. But as a result, I now get this message:
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Which tells me that the SDK Build Tools version is being set... somewhere!
Where else is the required build tools version set? How do I change it so that gradle will use the latest version, rather than being stuck on an old one?
I had the same problem. The buildtoolsversion is defined in build.gradle(Module.app).
I removed this line from the file and then the warning disappeared.

Where to install the gradle wrapper plugin with android studio

Android Studio tells me that the current gradle wrapper 2.8 is outdated and I should update to 2.10.
Warning:Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in C:\data\AndroidStudioProjects[projectname]\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip
I changed the url in gradle-wrapper.properties to gradle-2.10-all.zip but that didn't do anything.
I followed this answer to get gradle version 2.10:
Error:(1, 0) Plugin with id 'com.android.application' not found
But how of where do I install this plugin in Android Studio so it knows where to find it?
Go to:
Settings > Builds,Execution,Deployment > Build Tools > Gradle >Project-level settings
and set: Use default gradle wrapper
This tells Android studio to use the wrapper version from the file that you just updated.

Resources