Android Studio Stuck at Gradle Download on create new project

后端 未结 17 1611
盖世英雄少女心
盖世英雄少女心 2020-12-02 04:01

I have installed the new Android Studio. Everything was working fine but when I try to create a new project it gets stuck at downloading Gradle

相关标签:
17条回答
  • 2020-12-02 04:46

    This was also taking along time for me (slow connection).

    On Ubuntu (16.04), I was able to monitor the download progress by looking in:

    ~/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/ 
    

    running ls -al from this directory showed the gradle-3.3-all.zip.part file continuing to grow.

    The file ended up being 88M.

    Please note the 55gk2rcmfc6p2dg9u9ohc3hw9 (and gradle version) may be different for you, please change your command accordingly.

    0 讨论(0)
  • 2020-12-02 04:48

    Note : My answer seems quite long but its only 2 steps away if you want a correct way to configure with current project.

    I found what was the actual problem. Actually, each android project comes with its own version of gradle wrapper.

    have a look at dir

    projectname/gradle/wrapper

    here the properties file says the version of gradle that this project uses:

    #Mon Sep 08 13:53:18 PDT 2014
    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
    

    So the issue is if you dont have that version of gradle then it will download that version for you. For instance have a look at this dir, where it downloaded gradle versions for me

    /home/myusername/.gradle/wrapper/dists

    looks like

    Here it will try to download version of gradle if you dont have. If you are comfortable with downloading other version of gradle then you can wait till it completes else

    Workaround will be: 1. if project is on git clone it first.

    1. goto your projectdir/gradle/wrapper

    3.change version of distributionUrl to version that you already have : eg: for 2.2.1-all

    url will be

    distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

    4.copy gradle-wrapper.jar to your projectdir/gradle/wrapper from

    .gradle/wrapper/dists/gradle-2.1.1-all/4ryh47z6pv2tj9n03uiw8pzc6/gradle-2.2.1/lib/gradle-wrapper.jar(dont forget to rename gradle-wrapper2.2.1.jar to gradle-wrapper.jar)

    1. now import your project in studio.. and it works.
    0 讨论(0)
  • 2020-12-02 04:49

    Solution :

    1). Delete the C:\Users\username.gradle folder

    2). Download http://downloads.gradle.org/distributions/gradle-2.2.1-all.zip

    3). Create a new project in android studio.

    4). When this time it stucks at gradle building, Force close the android studio.

    5) Now go to C:\Users\username.gradle\wrapper\dists\gradle-2.2.1-all\c64ydeuardnfqctvr1gm30w53 (the end directory name may be different)

    6) Delete gradle-2.2.1-all.zip.lck and other files from this directory.

    7) Paste the new downloaded gradle-2.2.1-all.zip here.

    8) Run the android studio. :)

    0 讨论(0)
  • 2020-12-02 04:53

    I found the same issue happening on my laptop, despite waiting for quite a long time. This is what I did and it worked for me. Just force close the Android Studio and launch it again. This time, just open the existing project and let it take care of finishing up the process of building/downloading.

    Another option that you could possibly try is that if you look into File --> Settings, there is an option for Gradle location. You could go to the Gradle download site, download a local distribution of Gradle and point the Gradle location to that local directory.

    0 讨论(0)
  • 2020-12-02 04:53

    Android Studio comes with Gradle, but it does not have the command line gradle functionality.

    0 讨论(0)
  • 2020-12-02 04:54
    1. Open gradle-wrapper.properties
    2. Change From: distributionUrl=https/://services.gradle.org/distributions/gradle-4.4-all.zip To: distributionUrl=http://services.gradle.org/distributions/gradle-4.4-all.zip

    Note: 1. I dont care about SSL disable for downloading the gradle, but others might be sensitive, so its up to you. 2. Notice the gradle version, in my case its 4.4.

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