Build Failed with exception while trying to "Run" project

Hi,
I am a beginner and I am trying my first app using the default example of “Hello World” in Android Studio. When I try to “Run” the project I am getting an error message:-

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘MyFirstApplication’.

Could not resolve all artifacts for configuration ‘:classpath’.
Could not resolve com.android.tools.build:gradle:3.4.2.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.4.2.
Could not get resource ‘https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom’.
Could not GET ‘https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom’.
Connect to dl.google.com:443 [dl.google.com/172.217.24.238] failed: Connection timed out: connect
Could not resolve com.android.tools.build:gradle:3.4.2.
Could not get resource ‘https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom’.
Could not GET ‘https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom’.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/52.11.213.218, jcenter.bintray.com/52.35.38.36] failed: Connection timed out: connect

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 3m 15s
Connection timed out: connect

Any help in this regard will help a lot.

Thanks in Advance,
Shubhayan

I’m guessing you’re behind a proxy, can you hit the URLs in your browser?

See accessing the web via a proxy

Hi Lance,
Thanks for your prompt response.
I tried hitting both the URLs : 1>https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom
2>https://jcenter.bintray.com/com/android/tools/build/gradle/3.4.2/gradle-3.4.2.pom

I could hit the 1st one and the gradle-3.4.2.pom was automatically downloaded. The 2nd URL however gave this error message:-
{
“errors” : [ {
“status” : 404,
“message” : “Could not find resource”
} ]
} ===>This is the message I got on the browser.

Could it be possible that since second URL is “malformed” , the build process is giving error for both the steps? Is there anyway I could put the .pom file in a folder and make some changes in Settings to point to this .pom file?
Shubhayan

Well, the fact that you can hit one of the URLs in the browser that is failing in Gradle leads me to believe that you are behind a proxy. Can you confirm this?

Please follow the steps in the link in my previous response to configure your proxy settings

Hi Lance,
Your assumption was right. After making changes to configure the proxy settings, the Gradle Build was successful. Thanks a lot for this help.

However, I am not able to Run the project. When I try to “Run” the project (Alt+Shift+F10), a dialog box is appearing as 0.Edit Configurations 1.Gradle (and the gradle build under that, which was successful)

When I try to go into Edit Configuration it asks me to add a Template. I tried to add the Android App Template, but, here I am getting stuck.

In the Android App template there are various fields and one of them is Module Name. Here, in the drop-down list I am getting only “no-module” inside angled brackets (which is not displaying in this editor). In this case, wasn’t the module name “MyFirstApplication” supposed to appear? Do I need to create the module separately?

Please help me in going ahead.

Thanks in Advance,
Shubhayan

Hi ukLance,

With some tweaking I am able to run the app now.

Thanks and Regards,

Shubhayan Sengupta