skip to Main Content

I had to reinstall Android Studio for some reason. After installing, I am not able to build my project, getting this error

Failed to find Build Tools revision 31.0.0

There’s no warning or error showing in build.gradle file

enter image description here

I have tried changing compiledSdkVersion,buildToolsVersion and targetSdkVersion to 30

enter image description here

As you can see, if I change the version to 30, it is saying me to update to 31.

This is my project structure.

enter image description here

I have also tried Sync project with gradle files, Invalidate cashes, and restart, but no help. I don’t know what to do now.

5

Answers


  1. Chosen as BEST ANSWER

    Problem fixed.

    Previously the class path in my project level gradle was 4.2.2, it was not showing any warning though.

    classpath "com.android.tools.build:gradle:4.2.2"
    

    I had to replace it with

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

    And the project compiled successfully.

    @SweetD3v's answer was helpful.


  2. Make sure to replace the line containing classpath "com.android.tools.build:gradle:<gradle_version>" in your project level gradle with

    classpath "com.android.tools.build:gradle:4.2.2"
    

    It will add the latest gradle to your project.

    If you still getting the error, then check if your compileSdkVersion & targetSdkVersion are 31.

    Hope these little changes will solve your problem. 🙂

    You will also need to change the "distributionUrl" in your gradle-wrapper.properties to distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip

    And yes, as last option, try switching the buildToolsVersion from 31.0.0 to 30.0.2

    Login or Signup to reply.
  3. I changed my build tools version to 30.0.2 at the project structure tab and it worked for me

    Login or Signup to reply.
  4. in the app – build.gradle , change the buildToolsVersion to:

    buildToolsVersion "30.0.3"
    
    Login or Signup to reply.
  5. try this one, it worked for me

    compileSdk 31
    
    defaultConfig {
        applicationId "com.app"
        minSdk 23
        targetSdk 31
        versionCode 1
        versionName "1.0"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search