Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update gradle to 4.1 in Android Studio

My Android Studio shows me next window every start up

enter image description here

So I decided to update it. After click update in Android Studio build.gradle for a project opens. I change gradle version to 4.1 as suggested at pop up and click synchronize in Android Studio

classpath 'com.android.tools.build:gradle:4.1'

I see next error

Error:Could not find com.android.tools.build:gradle:4.1.  
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.jar 
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1/gradle-4.1.jar

I checked C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle and there is no 4.1 folder inside. Do I need to install it manually?

like image 828
Vitalii Avatar asked Nov 24 '17 21:11

Vitalii


People also ask

How do I upgrade Gradle wrapper to 4.8 1?

One way to upgrade the Gradle version is manually change the distributionUrl property in the Wrapper's gradle-wrapper. properties file. The better and recommended option is to run the wrapper task and provide the target Gradle version as described in Adding the Gradle Wrapper.


1 Answers

Android-gradle-plugin version 4.1 not released yet.

(Don't be confuse with Gradle and Android plugin for gradle)

Currently Android Studio 3.0.1 using Gradle-4.1 and Android-gradle-plugin 3.0.1

How I update gradle manually in Android Studio 3.0.1 :

  1. Find gradle folder inside your project

    Open gradle-wrapper.properties and change

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
    
  2. Open root build.gradle file and change in buildscript

    classpath 'com.android.tools.build:gradle:3.0.1'
    
  3. Additionally you need to add google() repo link in project repositories list and buildScript repo list.

    repositories {
        mavenLocal()
        mavenCentral()
        jcenter()
        google()        //<-   Add
    }
    
like image 200
Abhishek Aryan Avatar answered Sep 22 '22 15:09

Abhishek Aryan