How can i downgrade Gradle to 4.10.1 - android

I am using Android Studio 4.0.0. My project requires an earlier version of Gradle, version 4.10.1. I have been failing at this for weeks now. I have tried deleting the gradle folder on my project files, deleting the cache folder in C:/user/user_name/.gradle, I have changed the version on gradle.properties - all I get is an error that i should upgrade to version 6.1.1 of gradle.
Is there something im doing wrong? Please help

My project requires an earlier version of Gradle, version 4.10.1
That is over two years old. You should set aside some time to address whatever problems are in your build scripts that require an old version of Gradle.
Is there something im doing wrong?
In your project (top-level) build.gradle file, ensure that your com.android.tools.build:gradle dependency is set to 3.3.3:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.3.3"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The Android Gradle Plugin 3.3.3 still supports Gradle 4.10.1. Anything newer does not. See this table of Android Gradle Plugin and Gradle versions.

I have had this same problem yesterday when I inadvertently clicked the warning to update the gradle version on my Flutter project.
After some time, I realized that at least two places changed the version of gradle:
android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
android/build.gradle
buildscript {
// ...
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
}
}
You may want to change the version of those lines to one that corresponds to what you want.

Related

The project can be opened but can NOT be run now

I download tutorial codes from github, and I unzip it and copy paste it to where my android studio projects are. After I update to SDK 24.0.2, the project can be opened but can NOT be run now.
Pls write a bit more words for clear instructions in steps of what do I do since I am new to android studio. A lot of time I don't understand the terms you experts use.
Can NOT run the project? the green triangle run button is grey so I can NOT run it.
I got these red messages from Event Log
Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage().
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.
Consult IDE log for more details (Help | Show Log) (41 s 341 ms)
I tried the repo and with only a few changes in two files was able to run the project.
update the root-level build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Updated gradle version to 4.2.1 and added google() to resolve android dependencies.
updated my gradle distribution URL in gradle-wrapper.properties.
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Please see if the 6.7.1 is supported on your android studio or not else update to the latest as per your android studio supports, mine is the latest hence 6.7.1
That is it, just by changing these two files I was able to run that app.
Note: I just did bare minimum changes just to make the app run, ideally all the dependency and everything should be up-to-date but changing all those is out of the scope of this question.
I even committed the changes in the forked version of the app code. feel free to try
https://github.com/dk19121991/Court-Counter
Gradle is an app that Android Studio uses to manage loading the libraries of code the project is built with (among other things). But since this project you downloaded is about 5 years old, the version of Gradle in the project may not match up with what Android Studio's Android plugin can support.
Typically, the Gradle app is actually part of the project. You'll see it in the gradle/wrapper directory in the project. You can update the version by editing the file gradle-wrapper.properties, by changing the value in the distributionUrl line. I think you need to make the version at least 6.7.1 if you have a recently updated version of Android Studio, so change that line to look like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
The configuration of the project is in the files named build.gradle. The weird thing is, that project seems to have an incorrect duplicate of build.gradle in the root directory of the project (it looks like the one that should go in the app directory). So you can delete the contents of that build.gradle in your root directory and replace it with what would normally be there in a new project. I just copy-pasted this out of a new project. You can paste it into that file:
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And finally, you will want to update the build.gradle file that's in the app directory so it uses the version of Android you already have downloaded (probably SDK 30). So find these relevant lines in the file and change them:
compileSdkVersion 30
buildToolsVersion "30.0.3"
//...
targetSdkVersion 30
After you've made all the above updates, press the "Sync Project with Gradle Files" button near the right end of the toolbar to reload the project from Gradle. It will take a couple minutes because it will have to download the new Gradle version.

The Android Gradle plugin supports only Crashlytics Gradle plugin version 1.25.4 and higher

After couple of months of not working on my app I have decided to continue and before doing so I wanted to update all dependencies, libraries etc.
After 3h+ of a nightmare with googles nonsense I am at the final (probably not even close) stage.
This error of:
The Android Gradle plugin supports only Crashlytics Gradle plugin
version 1.25.4 and higher.
Is driving me nuts. I did a global search on my project of 1.25.4 and 1 result came up which was for the classpath 'io.fabric.tools:gradle:1.25.1' so I changed it to classpath 'io.fabric.tools:gradle:1.25.4' and hoped for the best.. But the same error keeps coming up every time I am trying to build the app..
Can anyone tell me what kind of magic potion should I spray this gradle so it actually starts to work?
add this to the root project's build.gradle:
buildscript {
repositories {
...
maven { url "https://maven.fabric.io/public" }
}
dependencies {
...
classpath "io.fabric.tools:gradle:1.26.1"
}
}
and this on top of the module level's build.gradle:
apply plugin: "io.fabric"

The android gradle plugin version 3.0.0-alpha1 is too old

While building a default project (black template) on Android Studio 3.0 Canary 1, I got the below error.
The android gradle plugin version 3.0.0-alpha1 is too old, please update to the latest version. To override this check from the command line please set the
ANDROID_DAILY_OVERRIDE environment variable to "d27b293f4c7c48dfe922ba160164f3fa511cb3b9"
Upgrade plugin to version 3.0.0-alpha1 and sync project Open File
What's wrong with the default setting?
Your code may be containing an outdated gradle plugin version (may be alpha1, or something like that) in your project build.gradle file. Update it to the latest alpha4 plugin like below:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
}
Apparently, the alpha1 is obsolete, even though it is not mentioned anywhere in document I could find.
In the project build.gradle, just change from
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
to
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath 'com.android.tools.build:gradle:+'
its not recommended to use +
Follow the steps :
Go to your Project structure
Click on project on left side panel
Update the Gradle version to 3.3
Click on Ok Button
let it sync and you will be done
After trying this solutions, I came with this:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
}
}
add
maven { url 'https://maven.google.com' }
to buldscript repositories.

How to find out which the latest version of any dependency we include in Gradle is?

In gradle I do not use dynamic versions because that could lead to indeterminate builds.
So I state my dependencies like so:
compile 'com.squareup.okhttp:okhttp:2.2.0'
However, how do I find out if there is a new version available and what its number is?
You can use a gradle-versions-plugin to do it. This plugin provides a dependencyUpdates task, which
Displays a report of the project dependencies that are up-to-date, exceed the latest version found, have upgrades, or failed to be resolved.
All you need to do, is to apply, by configuration of build.script dependencies, as:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
// classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5' // uncomment if you're using Gradle 1.x
}
}
And applying the plugin itself, with:
apply plugin: 'com.github.ben-manes.versions'
You could use this site to search your library latest version.

0.8.0 Gradle sync failed

So I'm trying to transfer to android studio but I've been getting this error all the time.
This is the only thing I'm getting in the log:
Error:Could not find method compile() for arguments [com.android.support:support-v4:20.0.0] on
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#50a8e746.
Please install the Android Support Repository from the Android SDK
Manager. Open Android SDK Manager
The problem is that I have android support repo installed as well as pretty much everything else so I really don't have any idea how to fix this.
I've even tried deleting the .gradle and let it download again but it didn't fix anything.
Here's my build.gradle (I did make changes to it since I was getting a build error):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
// do not use dynamic updating.
compile 'com.android.support:support-v4:20.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Android SDK:
Don't put module-level dependencies in the buildscript block. The buildscript block is for dependencies for the build system itself, i.e. if you were adding more Gradle plugins. To add dependencies for your modules, place them in the build.gradle file in the module directory.

Categories

Resources