1
ERROR: Could not find com.android.tools.build:gradle:3.5.2.
Searched in the following locations:
  - 

https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom -

https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom - https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar Required by: project : Open File

ext {
    var = '3.5.2'
   var1 = '3.5.2'
}// 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.5.2'

        // 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
}

we recived this error from my android studio when run my projects we used online and offline mod but they not worked corectly This error has confused me

The following code is related to wrapper

ext {
var = '3.5.2'
var1 = '3.5.2'
}// 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.5.2'

       // 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
}
Amir
  • 21
  • 1
  • 3
  • It's because gradle files have not downloaded compeletly.You should stay online and sync project. – Zahra Dec 03 '19 at 05:43
  • Have you add `google()` in your project's level `build.gradle` file? – Md. Asaduzzaman Dec 03 '19 at 06:00
  • Add your project level `build.gradle` file – Md. Asaduzzaman Dec 03 '19 at 06:00
  • https://stackoverflow.com/users/8144311/zahra I've been online but still see this error – Amir Dec 03 '19 at 06:01
  • yes i have google() in my project https://stackoverflow.com/users/2637449/md-asaduzzaman – Amir Dec 03 '19 at 06:02
  • Do not add this in comment section. Add this gradle file in question by updating it. – Kaushik Burkule Dec 03 '19 at 06:04
  • Then check your gradle setting in android studio whether **Offline Work** is enable or not? – Md. Asaduzzaman Dec 03 '19 at 06:06
  • https://stackoverflow.com/users/2637449/md-asaduzzaman i try in offline mode whit entered path in setting and online mode in both of them i have this error – Amir Dec 03 '19 at 06:08
  • once try it Invalidate/caches and restart and also quit android studio and click on make project and rebuilt project again. – Twisha Kotecha Dec 03 '19 at 06:44
  • Show your gradle-wrapper.properties – Arnold Brown Dec 03 '19 at 06:56
  • https://stackoverflow.com/users/12040838/twisha-kotecha i try invalidate caches and My problem was not solved – Amir Dec 03 '19 at 09:32
  • https://stackoverflow.com/users/5049244/arnold-brown I edited the question code and wrapper is added to my question – Amir Dec 03 '19 at 09:39
  • This question at https://stackoverflow.com/questions/25260172/how-to-check-the-gradle-version-in-android-studio/35847490 solved my issue. You can get latest version from menu **File -> Project Structure...**, and then ensure correct(or latest) **Gradle Plugin version** in `build.gradle` and **Gradle version** inside `gradle-wrapper.properties`. – 林果皞 Jun 24 '20 at 19:57

3 Answers3

1

This problem basically occurs when you are trying to load an old project. The best solution as of my knowledge is to download the links one by one, the project is showing and sync it. Check out the build Gradle files for any outdated dependencies. Check out if you have

google()

repo in your project. Make sure you find this line in your dependencies.

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
  • i have this line in my code and when i create a new project again recived this error – Amir Dec 03 '19 at 06:17
  • @Amir You're having the Gradle links so you should download it. Otherwise, you uninstall the Android Studio. Install it again set the correct path variables. If you need any assistance you can search for the same on Youtube. And make sure whenever you are using Android Studio you should be connected to a decent network. Thank you. – Vishal P Vijayan Dec 03 '19 at 12:48
1

I also had this problem on Linux (ubuntu)

I tried different ways but the problem still didn't work out.

Finally, I remove /home/(user)/.gradle directory and restart Android Studio and this error fixed.

ultra.deep
  • 1,699
  • 1
  • 19
  • 23
0

Follow these steps:

  1. Copy paste the below code into Project level build.gradle file:
// 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.5.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

  1. Clean your project from Build > Clean Project
  2. Rebuild you project from Build > Rebuild Project
  3. Make Project from Build > Make Project
  4. Then, File > Invalidate Caches/Restart
Shariful Islam Mubin
  • 2,146
  • 14
  • 23