I updated the Android Studio to the latest version (3.6.1) and Gradle Plugin is not found now
Asked Answered
S

9

14

In an Android application,
I updated the Android Studio to the latest version (3.6.1)

Now when Syncing Gradle, the Gradle Plugin is not found with the errors as following:

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':classpath'.

And

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.tools.build:gradle:3.0.0.

It's driving me crazy cause I change the Gradle Version and Gradle Plugin Version to several other possibilities but again the Gradle Plugin is not found with the same error

Build.Gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And Gradle.Wrappers.Properties file:

#Thu Mar 05 15:41:52 IRST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

Edit :
I added the following data too:

Compile Sdk version: 25
Build Tools Version: 25.0.3

Selfgovernment answered 5/3, 2020 at 12:32 Comment(2)
Facing the same issue. Did you find any solution?Cabin
Check this : https://mcmap.net/q/829765/-android-studio-3-6-1-with-gradle-plugin-version-3-6-1-and-gradle-version-5-6-4-not-workingRydder
R
14

This is what worked for me :

Open the build.gradle file from your app folder, it should look similar to this

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

add google() to repositories in -buildscript and allprojects just like this :

buildscript {
    repositories {
        google()       // here
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'
    }
}

allprojects {
    repositories {
        google()      //and here
        jcenter()
    }
}

In Android Studio, go to File -> Project Structure.. [ shortcut : Ctrl + Alt + Shift + S ]

In the Project tab -> Android Gradle Plugin Version -> 3.6.1 and Gradle Version -> 5.6.4 |||

Last, under the Module tab, make sure the compile sdk version is > 14 (ie: 25, 28 or 29..)

Rettke answered 18/3, 2020 at 22:51 Comment(0)
F
3

In your gradle-wrapper.properties file, change the distributionUrl to:

https://services.gradle.org/distributions/gradle-5.6.4-all.zip

The gradle-wrapper.properties file content should be like this:

#Wed Mar 11 00:28:24 EET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Frequent answered 10/3, 2020 at 22:34 Comment(0)
B
1

I did not find a solution, the only thing was to return this In the built.gradle(project)

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

to this

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

and it worked!

Bengurion answered 17/3, 2020 at 17:51 Comment(0)
S
1

I first received the following error

   > Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing org.gradle.java.home in gradle.properties.

And for that I followed the steps below

First of all, you need to change the JDK version to 11, which you can get help from the link below

https://mcmap.net/q/53474/-android-studio-error-quot-android-gradle-plugin-requires-java-11-to-run-you-are-currently-using-java-1-8-quot

I will share the steps I have done in order

  1. In gradle.properties in C:\Users{USER_NAME}\.gradle

set below flag for disable daemon gradle

org.gradle.daemon=false

or run the below command :

Windows :

(if not exist "%USERPROFILE%/.gradle" mkdir "%USERPROFILE%/.gradle") && (echo. >> "%USERPROFILE%/.gradle/gradle.properties" && echo org.gradle.daemon=false >> "%USERPROFILE%/.gradle/gradle.properties")

UNIX :

mkdir -p ~/.gradle && echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties

  1. I set the below flag in .idea\compiler.xml

set :

<project version="4">
  <component name="CompilerConfiguration">
    <bytecodeTargetLevel target="11" /> // <--- change this line
  </component>
</project>
  1. I set the below flag in .idea\gradle.xml

set :

<project version="4">
  <component name="GradleMigrationSettings" migrationVersion="1" />
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="testRunner" value="GRADLE" />
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="gradleJvm" value="Android Studio default JDK" /> // <-- this line
        <option name="modules">
          <set>
            <option value="$PROJECT_DIR$" />
            <option value="$PROJECT_DIR$/app" />
            <option value="$PROJECT_DIR$/core_data" />
          </set>
        </option>
        <option name="resolveModulePerSourceSet" value="false" />
      </GradleProjectSettings>
    </option>
  </component>
</project>
  1. Set languageLevel="JDK_11" in .idea\misc.xml

you can also change JDK version from File | Settings | Build, Execution, Deployment | Build Tools | Gradle and set Gradle JDK to version 11

enter image description here

I hope it helps you

Sextet answered 12/3, 2022 at 11:21 Comment(0)
P
1

I received the following error

Could not resolve all artifacts for configuration ':classpath'.
 > Could not find gradle-api-3.6.4.jar (com.android.tools.build:gradle-api:3.6.4).

I just upgraded my gradle-wrapper.properties from

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

to the newest gradle version

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
Pomposity answered 3/3 at 16:53 Comment(0)
U
0

Another issue: using <TextClock> in a layout also causes problems. Android Studio will not 'find' the layout! Workaround: comment out the then un-comment it out. The build should now work!

Ulla answered 31/3, 2020 at 22:7 Comment(0)
A
0

Write google() at top of jcenter() in main build.gradle file as shown below:

// 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.6.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
Abatis answered 19/6, 2020 at 6:42 Comment(0)
P
0

Check this link from Developers site which mentions every Gradle version and it's corresponding plugin version. here Update Gragle

More clarification for beginners:

First you have to make sure which Gradle version you have in - for example "C:\Users\username.gradle\wrapper\dists", which you can also find in "gradle-wrapper.properties (Gradle Version)" file, in

distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

then look at the Developers site for it's corresponding plugin version, which you will then modify in build.gradle (Project:your_project_name) file in

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.0' }

finally sync your project and you're good to go, in some cases android studio may download the latest Gradle version so if this's your case, just give it a moment and it will sync and build your project after that.

Plummy answered 12/10, 2020 at 22:17 Comment(0)
N
0

in my case this dependency was causing the issue 'com.etebarian:meow-bottom-navigation:1.3.1' when I deleted that dependency then error went out...

Nutrilite answered 12/3, 2022 at 6:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.