Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: gradle version 2.2 is required. Current version is 6.5.1

I am coding a Java project in Android studio 4.0. This is my current Gradle version (6.5.1). (In gradle-wrapper.properties)

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip

error said:

Studio gradle version 2.2 is required. Current version is 6.5.1.

Then I turn my gradle version into 2.2, and it gives me another error:

Support for builds using Gradle versions older than 2.6 was removed in tooling API version 5.0.
You are currently using Gradle version 2.2. 
You should upgrade your Gradle build to use Gradle 2.6 or later.

I've tried everything to do and read questions and articles. But seeing no hopes. enter image description here

I am new to android app design. Any advise will be appreciated!

update 1(build.gradle):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.pcschool.map"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
            'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.google.android.gms:play-services:7.3.0'
}
like image 852
Chunhao Avatar asked Sep 05 '25 03:09

Chunhao


2 Answers

Android Studio uses a plugin to support gradle. Each version of the plugin supports a range of gradle versions.

In your case it sounds like you have a recent version of Android Studio, running a recent version of the gradle plugin, supporting the latest versions of gradle.

Your project however requires an older gradle version. Since the gap is pretty big (6.5.x to 2.2) your current version of the plugin will not support this old gradle version. You would have to downgrade the plugin, but doing so you'd probably also have to downgrade Android Studio to support the old plugin version.

I highly suggest changing the version of gradle that your project depends on to something more recent. You'll definitely have to make some changes to your build script(s) since a lot of things have changed since 2.2, but it will be worth it in the long term. Android Studio might even encourage you to do that when you launch it. If not, you can do it under Project Structure in the File menu.

If you for some reason can't upgrade, you'll need to find an older version of Android Studio that supports a version of the gradle plugin that in turn supports gradle 2.2.

like image 167
TofferJ Avatar answered Sep 09 '25 16:09

TofferJ


Maybe you can try to add these lines in your build.gradle:

buildscript {
    repositories {
        mavenCentral();
        jcenter();
        google();
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
    }
}

And the newest gradle version can be fetched on https://developer.android.com/studio/releases/gradle-plugin

like image 22
无风引漩 Avatar answered Sep 09 '25 17:09

无风引漩