17
votes

Error :

Could not find com.android.tools.build:gradle:4.0.1. Searched in the following locations:

https://jcenter.bintray.com/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.0.1/gradle-4.0.1.pom

Required by: project : Open File

*** looks like google() and jcenter() are not working as expected.***

I migrated from android studio 2.3.3 to 4.0.1 and this error happened.

what is my problem???? plz tell me if you need more information .

thank you for your answer :)

3
Have you tried clearing your build directory and rebuilding the project from scratch? - D. McDermott
yeah. that's not work - Sadegh
Please use mavenCentral() for dependencies repository entry, jcenter() will be deprecated developer.android.com/studio/build/jcenter-migration - ecle

3 Answers

30
votes

I think the solution will only work in Iran . If you know that 's working out of Iran , please note in the comments .

why would a proxy be necessary? There have been a number of technology-related sanctions against Iran.

go to -> File | Settings | Appearance & Behavior | System Settings | HTTP Proxy, and choose -> manual proxy configuration. set host name: fodev.org and set port number: 8118 . now you must find gradle.properties file. that must be in: Windows: C:\Users\YOURUSERNAME.gradle\gradle.properties OR for Linux: ~/.gradle/gradle.properties . if does't exist, create that yourself. and copy this :

systemProp.http.proxyHost=fodev.org
systemProp.http.proxyPort=8118
systemProp.http.nonProxyHosts=*.jitpack.io, *.maven.org
systemProp.https.proxyHost=fodev.org
systemProp.https.proxyPort=8118
systemProp.https.nonProxyHosts=*.jitpack.io, *.maven.org

now you can sync project.

IMPORTANT : after install build.gradle 4.0.1 (or every version), back this settings to before and remove codes

3
votes

Deleting and reinstalling my node modules seemed to work for me

rm -rf node_modules
yarn install
-1
votes

If you are importing a project from github or other.

  1. Close the project in Android Studio. File -> Close project.
  2. In file explorer, delete .idea, .gradle and gradle if there are any inside your project folder. (.idea, .gradle are hidden items. Make sure hidden items are shown in your file explorer) or if you are using command line, do ls -a
  3. Open the project in Android Studio again.
  4. Done.