Android Studio stuck on gradle resolving dependencies

后端 未结 15 1138
臣服心动
臣服心动 2020-12-04 22:11

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

相关标签:
15条回答
  • 2020-12-04 22:14

    I have the same problem.And I finally solved it.

    1. Download your Gradle, it is in your Gradle-wrapper.properties.for example

      https\://services.gradle.org/distributions/gradle-3.3-all.zip

      And unzip it anywhere.

    2. go to File-> Settings-> BUild, Execution, Deployment -> Gradle, select use local gradle distribution and offline work, then set the Gradle Home as the path where you unzip the gradle-3.3-all.zip.Like this /opt/android-studio/gradle/gradle-3.3.

    3. Click Try again, it will build very quickly, because it won't connect to jcenter anymore.It uses the local gradle.

    P.S.: If you add new dependencies, you have to turn off offline work.

    0 讨论(0)
  • 2020-12-04 22:15

    check if your android studio's gradle is in offline mode. if yes then uncheck offline mode.

    path: file->setting->Build Exexcution -> gradle ->offline work

    0 讨论(0)
  • 2020-12-04 22:16

    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

    0 讨论(0)
  • 2020-12-04 22:17

    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

    0 讨论(0)
  • 2020-12-04 22:20

    Network problem. After I restart Android Studio and use a proxy everything is OK now. During the Gradle build , Android Studio need to download some file from the Internet. Make sure you have a good connection.

    0 讨论(0)
  • 2020-12-04 22:21

    Re-install latest version of Android Studio.

    Install in the directory such that that directory has no white space, meaning space char.

    Before creating any project in the studio, first update it's components using sdk manager.

    Create a workspace such that it has no white space in it's path.

    0 讨论(0)
提交回复
热议问题