I'm new to Android Studio and while creating a new project it stuck at resolving dependencies :app:_debugCompile
.
I waited for sometime and even tried to create a new project, but that didn't work. Here's a screenshot of the window:
Here's the contents of build.gradle
file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
maybe you have problem to connect to the internet to download gradle, you can set in http proxy
File->Settings->Http Proxy->Manual proxy configuration->HTTP
Host name:172.16.26.2(that's mine) Port number:8080
of course,you need to change the Host name,the proxy you use
100% fix for you Android lover
you can ether fix it for each of your new project or just fix it for every new project you open. I'm gonna explain both:
** For each project separately :
When you create a new project and when you stuck at: Gradle: Resolve dependencies ':app:_debugCompile' just hit Cancel button after that the process may continue again and you may see at the bottom of Android studio that you stuck on the same point you can click on the red Cancel button beside progress bar now too
so at this point your new project should open but with some error like : Error: Could not run build action using gradle .........
Now open the Project tap in the left side of android studio window (it has green icon of android studio on it) now go to this path: Gradle Scripts > build.gradle(project:your project name)
after double clicking on it you will see the contents of it in a editor at the right side of it
just look for the lines :
allprojects {
repositories {
jcenter() }
}
and just select jcenter() and nothing more and replace it with below line:
maven { url 'http://repo1.maven.org/maven2' }
after this just hit the Try Again button at the top of the editor
That's it now your project will rebuild in no time without any problem (don't forget to be connected to internet) this method just work for this project and if you open another new project you have to do the same thing to get it working
**Now the fix for every new project at once:
first open Notepad as administrator (just right click on it and click on Run as administrator)
Go to below path of your Android Studio installation path with Notepad (when you open Notepad as administrator you can drag and prop file in it, so open the below path in notepad): the default path is :
C:\Program Files\Android\Android Studio\plugins\android\lib\templates\gradle-projects\NewAndroidProject\root
you can't see anything in this path and you have to set the File type chooser to All Files at the right bottom side of file opener window
Now open build.gradle.ftl
press Ctrl+F keys and search for:
allprojects
in front of the the above word you search for you can see this line:
{ repositories { jcenter()<#if mavenUrl != "mavenCentral">
all you have to do is to select just jcenter() and nothing more and replace it with below line:
maven { url 'http://repo1.maven.org/maven2' }
Save the file and close the Notepad
That's it now your new project build time is less than 30 seconds depending on your system hardware.
Hit thanks if this solved your problem Regards
Killing the process or restarting the system helped me. Now it works perfectly fine...
P.S: A quote from the sitcom The IT Crowd:
Did you try turning it off and on again?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With