0

After installing Android studio and creating a new project, I get the following message: enter image description here

and in the "Build: Sync" section I get the following error:

enter image description here

After clicking in "Try Again" nothing changes. How can I fix it?

Ali
  • 3,346
  • 4
  • 21
  • 56
ANDY
  • 15
  • 3
  • please refer this [link](https://stackoverflow.com/a/30794890/4748607) for setting gradle offline and sync. – Nirav Bhavsar Nov 14 '18 at 07:37
  • please check Offline Mode is **ON** or **OFF** in Gradle Setting. if is **Off** then please turn **ON** – Ali Nov 14 '18 at 07:44

2 Answers2

0

You need to add the google() repo in the top level gradle file, also it should be before jcenter():

buildscript {
  repositories {
          google()
          jcenter()
      }


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

allprojects {
     repositories {
              google()
             jcenter()
  }
}

Check gradle is on offline or online mode:

File -> Settings->Build,Execution,Deployment->Gradle->uncheck Offline work->Click the OK button->Rebuild the Project
Sultan Mahmud
  • 1,245
  • 8
  • 18
  • Thank you for trying to help. The Offline box for the Gradle is uncheck and in the section build.gradle it seems that the google() repo is before jcenter(). Here's a link to it (https://i.imgur.com/vR50GjW.png). – ANDY Nov 14 '18 at 19:38
  • Also, here's what I see on build.gradle: `buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' // 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 } ` – ANDY Nov 14 '18 at 19:39
0

Try to check your proxy. make sure you have access to jcenter URL. It happens to me when trying to make a new project or add dependencies in my office because of proxy restriction. To check proxy, open:

File > Settings > Appearance & Behavior > System Setting > HTTP Proxy

You can use auto-detect proxy or manual proxy if you have proxy on your network. Hope it help.

edof
  • 18
  • 5